question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Removing failing fields from JSON?

See original GitHub issue

We’re interested in using a JSON schema to produce valid CSL JSON Items (citation styles language). Our CSL inputs contain many fields that are not part of the schema. In addition, some fields have values that violate the schema. Therefore we would like to perform the following two steps:

  1. Removing fields not part of the specification (when additionalProperties is false). Cross-referencing SO44694835.

  2. Removing fields whose values violate the schema. Here we would want to remove the lowest-level errors, such that we don’t remove entire objects because of a single deeply nested error contained within them.

Is this doable with jsonschema or should we look to an alternative solution? Any suggestions will be appreciated.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
dhimmelcommented, Aug 22, 2018

Thanks @Julian for the advice. I had looked at the code in the FAQ, but with my limited understanding of the internals of this package, it was a bit difficult. However, of course, I still think it would be a great builtin feature for your package should it be in scope sometime in the future.

For others interested in this feature, we ended up implementing something in https://github.com/greenelab/manubot/pull/49. See the relevant code here and the relevant test suite here, where we note:

The fidelity of the remove_jsonschema_errors implementation is difficult to assess theoretically, therefore its performance should be evaluated empirically with thorough test coverage.

0reactions
aj07mmcommented, Jun 21, 2022

this doesn’t work with polymorphic schemas

Read more comments on GitHub >

github_iconTop Results From Across the Web

Removing failing fields from JSON? · Issue #448 - GitHub
Removing fields whose values violate the schema. Here we would want to remove the lowest-level errors, such that we don't remove entire objects ......
Read more >
Removing fields from json string - java - Stack Overflow
The "foo" in your JSON is an array. You should do: ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.
Read more >
Solved: How to remove few fields from JSON array response?
Inside Javascript policy, I'm taking the whole payload in a variable, converting it to an array, mapping required fields to another array, and...
Read more >
How to remove a few fields from the JSON array response ...
JSON is a text data format that is easily converted into native datatypes. ... How do I remove a few fields from the...
Read more >
In JSON, how to remove "Data" and "Item" - Forums - IBM
Removing (renaming) these can be tricky. The 'Data' object is fairly easy, but the 'Item's are not. Here's a simple case to change...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found