On Jun 11, 2013, at 9:52 AM, Kevin Swiber <[email protected]> wrote: > On Tue, Jun 11, 2013 at 8:57 AM, Chris Dew <[email protected]> wrote: > I was quite concerned when I couldn't find a formal specification for the > simple newline delimited JSON over TCP framing (which I have successfully > used on multiple projects). > > > So I wrote one: > > http://www.jsonstream.org > > > Have I missed a IETF or W3C RFC for this? > > Hey Chris, > > I think most streaming parsers just wait for the beginning object or array to > close and don't necessarily need a delimiter between objects. > > A lot of work in "streaming JSON over TCP" has been focused on binary > serialization formats as a whole, not necessarily chunk delimiters.
I've taken a similar streaming approach to Chris, but using '\0' as a delimiter. It's easier to make work when you don't have a flexible/robust JSON parser because you can do chunking in a stateless way. When chunking using object/array open tokens, you either need to implement a stateful scanner to match nested opens/closes. Or a more robust JSON parser that is itself streaming, or a parser that can tell you where it stopped parsing the last packet. Oh, and not throw an error when it encounters multiple top-level items and partial JSON fragments. It is much simpler (and faster) to split on characters that are not permitted in a JSON document. I chose '\0' because we were using some human-created plaintext JSON files that did have real '\n' whitespace. -- -- 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 --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
