4 ms·
Sorry, I would never use this. Before I consume any json from any source or for any purpose I validate it. Lazy loading serves no purpose if you need validati
by fanseepawnts 3y ago
Sorry, I would never use this. Before I consume any json from any source or for any purpose I validate it. Lazy loading serves no purpose if you need validation.
Hint: you need validation.
- creatonez 3y agoThe purpose seems to be for when parsing a JSON document where large parts of it are irrelevant to your use case. It seems cursed, but it seems that using this method you can leave lee-way for unparsed parts and still validate what you are actually using, if the parser is robust enough.
- beached_whale 3y agosmdjson is validating as it moves through the file
- ysleepy 3y agoYou need a parser for validation, - preferably a fast, possibly even a streaming one.
- samatman 3y agoWhich this is not. A validating parser, that is. The paper clearly indicates that invalid JSON like [1, 1b] will pass, unless your code happens to try and decode the 1b.
- Seb-C 3y agoThere are cases where the json does not come from a user input and can be trusted without a validation layer. Also you may want to stream-validate it.
- fanseepawnts 3y ago[dead]
- andix 3y agoIf you already know it's validated and coming from a trusted source there is no reason to validate it again. For example json from a database that only allows inserting valid json. In such cases even the structure might be known and some assumptions can be safely made.
- fanseepawnts 3y agoSorry theres no such thing as prevalidated JSON. You can do it in a sidecar all you want. In-process validation is required. There are no trusted sources. Your confusing valid json with valid json according to a schema for a specific purpose. Lazy loading JSON parsers have no nead to exist, at all, ever. This is why they dont exist.
- jesprenj 3y agoYou don't need to load the entire JSON object as a DOM into RAM just to validate it. Validation can easily be done using a stack and iteration with space complexity being the depth of the JSON (stack) and time being linear to the length of the object.