Removing failing fields from JSON?
See original GitHub issueWe’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:
-
Removing fields not part of the specification (when
additionalProperties
isfalse
). Cross-referencing SO44694835. -
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:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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:
this doesn’t work with polymorphic schemas