3 ms·
In specific contexts such as this one you don't need arbitrarily complex JSON, you just need to validate that the JSON structure respects not just JSON itself b
by lloeki 7y ago
In specific contexts such as this one you don't need arbitrarily complex JSON, you just need to validate that the JSON structure respects not just JSON itself but also the protocol specification at hand while you parse, and bail out when it doesn't, so you can have a dedicated, fast parser tailored for the use case, instead of first parsing general JSON then validate its content.
Anyway, for being a Fasmail user, JMAP rips IMAP to shreds in terms of performance. I've been following JMAP from afar and waiting for Fastmail to publish this for a long time.
- rhabarba 7y agoSo you're suggesting to write a tailored JSON parser for each use case? Sounds convincing over my preferred approach...
- lloeki 7y agoNot for each use case of everything, anywhere, of course. This specific use case is important enough to warrant a dedicated parser though, and has benefits both in performance and in security. People have ben actively doing this for XML with streaming parsers that emit events, where you don't just validate XML itself but the semantics of the payload you're receiving, and bail out early instead of parsing the whole XML into a DOM then validating the DOM structure and values.