The key is to avoid using something as a delimter that will show up as a
matter of course in JSON objects. Twitter uses \r\n pairs for their API
(which I believe they serve up as application/json). They may also include
blank lines. This format can be parsed using something as simple as the
following:
function parse_JSON_stream(s) {
return s.split("\r\n").filter(function (l) { return l !=
'';}).map(function (l) { JSON.parse(l); });
}
Using \n all by itself is safe if you encode with JSON.stringify and don't
specify a third parameter.
On Wednesday, May 23, 2012 3:00:15 PM UTC-7, Mark Hahn wrote:
>
> > it seems that the work on the client side to do streaming parsing
> gets much harder
>
> I don't understand? Parsing commas is hard? However you planned on
> parsing newlines could parse commas instead.
>
>
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en