4 ms·
Well the good libraries have option flags that will allow you to handle JSON as found in the wild.
by JackFr 6y ago
Well the good libraries have option flags that will allow you to handle JSON as found in the wild.
- majewsky 6y agoThat's not JSON, though. It's absolutely something else. Maybe a JS snippet. Maybe YAML. Definitely not JSON, though. (Some JSON libraries do have option flags, but usually it's about whether, during deserializing into a known type, unknown fields are an error or silently ignored. Or whether C-style comments are an error or considered as whitespace.)
- JackFr 6y agoIt may not be JSON but it’s out there in the wild. A lot. Let’s say I’m scraping a website. I can: 1) complain to the owner that “it’s not JSON”. 2) write a parser for a syntax that has no spec, (it’s not JSON, but it sure looks an awful lot like JSON with unquoted keys.) or 3) Set ALLOW_UNQUOTED_FIELD_NAMES to true in the Jackson library.
- Izkata 6y ago> Maybe a JS snippet. While acceptable, also misleading: JS only does string keys, but unlike JSON it'll convert whatever it's given into strings. Not a problem most of the time, since it'll do the same conversion for both accessing and setting, but good to be aware of if you're doing something like iterating Object.keys()
- jimmynest 6y agoI use https://jsonformatter.org/json-parser https://jsonformatter.org/json-parser sometime to parse json and to validate.