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.
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

