Please help with writing spec for async JSON APIs
bjouhier at gmail.com
Tue Aug 4 21:09:29 UTC 2015
JSON is not that hard to parse incrementally. The i-json parser is
implemented in C++ with a fallback JS implementation. The C++
implementation is less than 1000 locs and the JS implementation less than
400 locs. The C++ implementation is 1.65 times slower than JSON.parse but,
unlike JSON.parse, it does not use any V8 internals and I have spent very
little time to optimize it. So there is room to get closer to JSON.parse.
Parsing JSON incrementally has some advantages:
- No need to specify a new format.
- The parser is generic and not limited to feeds. It can handle big,
arbitrarily complex JSON payloads.
- Parsing can be performed by a tight automata in a single pass over the
source buffer, without any backtracking nor lookahead. This may be more
efficient than a 2-stages approach in which the first stage identifies the
fragments and the second one passes them to JSON.parse.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss