Nick Niemeir (2013-12-08T19:50:48.000Z)
domenic at domenicdenicola.com (2013-12-10T00:59:31.373Z)
On Sun, Dec 8, 2013 at 10:57 AM, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote: > However, that would not necessarily be the case for an application that is > using a streaming JSON parser. > ```json > { > "allenwb": "there is an objectively observable order to the members of a > JSON object", > "JSON WG participant 1": "It would be insane to depend upon that > ordering", > "allenwb": "not if there is agreement between a producer and consumer on > the meaning of the ordering", > "JSON WG participant 2": "But JSON.parse and similar language bindings > don't preserve order", > "allenwb": "A streaming JSON parser would naturally preserve member > order", > "JSON WG participant 2": "I din't think there are any such parsers", > "allenwb": "But someone might decide to create one, and if they do it will > expose object members, in order", > "allenwb": "Plus, in this particular case the schema is so simple the > application developer might well design to write a custom, schema specific > streaming parser." > } > ``` One good example of a streaming parser is the npm package JSONStream. If you wanted to accept conversations on standard in and output allenwb's statements on standard out you could use this node program: ```javascript var JSONStream = require('JSONStream') process.stdin .pipe(JSONStream.parse('allenwb')) .pipe(process.stdout) ``` With this JSON text the output is the expected: ``` there is an objectively observable order to the members of a JSON objectnot if there is agreement between a producer and consumer on the meaning of the orderingA streaming JSON parser would naturally preserve member orderBut someone might decide to create one, and if they do it will expose object members, in orderPlus, in this particular case the schema is so simple the application developer might well design to write a custom, schema specific streaming parser. ```