>> Several streaming json parsers support this already out of the box. >> They ignore the newlines and know when a json body ends because of the parser state.
Pretty much sums it up :) Nuno On Thu, May 24, 2012 at 6:05 PM, Tim Caswell <[email protected]> wrote: > application/x-json-stream -> JSON messages (without extra whitespace) > newline separated. > > Several streaming json parsers support this already out of the box. They > ignore the newlines and know when a json body ends because of the parser > state. People who don't have a streaming parser, can search for the > newline instead and do their own de-framing. Either way, it's very trivial > to parse. > > var parser = new StreamingParser({ multivalue: true }); > req.pipe(parser); > parser.on("message", function (message) { > // ... > }); > > On Thu, May 24, 2012 at 11:52 AM, Isaac Schlueter <[email protected]> wrote: > >> On Wed, May 23, 2012 at 3:00 PM, Mark Hahn <[email protected]> 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. >> >> It goes from trivial (because you don't have to inspect the JSON at >> all) to not-trivial (because you do). >> >> JSON can contain commas, but unless it's created using a pretty-indent >> argument, it can never contain newlines. This means that your parser >> only has to be aware of a single byte, and can dumbly skip over >> everything else. >> >> I think what we need is a new standard for \n delimited JSON streams. >> It addresses a slightly different need (since you won't ever parse the >> whole thing all at once, and it may not even ever end), and requires >> the sender to not send pretty-formatted JSON, so that each object is >> guaranteed to be a single line. >> >> Actually, I think that's basically the spec: >> >> 1. Lines are delimited by \n (0x0A) >> 2. Each line must be a valid JSON string in UTF-8 encoding. >> >> The only thing we're lacking is a mime-type. >> >> -- >> 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 >> > > -- > 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 > -- 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
