how to make JSON decoding throw an error for superfluous elements in JSON input
See original GitHub issueHi!
How can I make the Circe JSON decoding stricter such that whenever it encounters an element (in the JSON input string) that is not in the target class X (decode[X](string)
) it throws an error. Currently, with the default settings (circe 0.9.1), superfluous elements are silently ignored.
For me (in my application) superfluous elements are an input error, so I need the error to be thrown by circe.
Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:10 (5 by maintainers)
Top Results From Across the Web
json — JSON encoder and decoder — Python 3.11.1 ...
It should return a JSON encodable version of the object or raise a TypeError . If not specified, TypeError is raised. If sort_keys...
Read more >Can you use a trailing comma in a JSON object?
With Relaxed JSON, you can have trailing commas, or just leave the commas out. They are optional.
Read more >JSON and serialization - Flutter documentation
By looking at the dart:convert documentation, you'll see that you can decode the JSON by calling the jsonDecode() function, with the JSON string...
Read more >How to serialize and deserialize JSON using C# - .NET
Learn how to use the System.Text.Json namespace to serialize to and deserialize from JSON in .NET. Includes sample code.
Read more >PARSE_JSON - Snowflake Documentation
If the PARSE_JSON function is called with an empty string, or with a string containing only whitespace characters, then the function returns NULL...
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 FreeTop 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
Top GitHub Comments
yeah, I answered just to share where I’ve seen this 😃
Well, that’s another perfectly valid solution in my opinion. One reason you might not be able to do that is that you have to support older clients, and
elements
is something new in the payload.@travisbrown Sure: I’ve tried the #708 example (with circe 0.9.1). In that example, decoding should work for
good
andshouldBeGood
, although it does only forgood
.