4 ms·
What’s the benefit of `jsonriver` over one of the myriad of “best effort” parsers[0][1][2] in a try/catch loop while streaming? [0]https://github.com/beenotung
by jumploops 1y ago
What’s the benefit of `jsonriver` over one of the myriad of “best effort” parsers[0][1][2] in a try/catch loop while streaming?
[0]https://github.com/beenotung/best-effort-json-parser https://github.com/beenotung/best-effort-json-parser
[1]https://github.com/unjs/destr https://github.com/unjs/destr
[2]https://www.npmjs.com/package/json-parse-even-better-errors https://www.npmjs.com/package/json-parse-even-better-errors
- rictic 1y agoGood question. jsonriver is well optimized, exhaustively tested (tens of thousands of test cases), and provides a number of potentially useful invariants[0] about its parsing. jsonriver's performance comes primarily from simplicity, and doing as little work per character as we can. Repeatedly reparsing from scratch on the other hand gets expensive quick, your parse time is quadratic in the length of the string to parse. [0] https://github.com/rictic/jsonriver?tab=readme-ov-file#invariants https://github.com/rictic/jsonriver?tab=readme-ov-file#invar...
- jumploops 1y agoI've been looking for a better solution for awhile now (if you couldn't tell), and will definitely try out jsonriver for our use-case. Thanks!