[erlang-questions] fast JSON parser in C

Bob Ippolito <>
Fri Jul 25 16:55:32 CEST 2008


On Fri, Jul 25, 2008 at 4:12 AM, Serge Aleynikov <> wrote:
>
> Also, this is not specific to the thread, but while on this subject, I
> don't quite understand why JavaScript Object Notation (JSON) is so
> heavily demanding double quoting everything in contrast to the
> JavaScript Object Notation built into all browsers.  What I mean is that
> the javascript interpreters built into browsers happily understand this
> notion of an object:
>
>        {foo: 1, bar: "value"}
>                or
>        {foo: 1, bar: 'value'}
>
>
> whereas in JSON this would require to be written as:
>
>        {"foo": 1, "bar": "value"}

... because it is a lot simpler and easier to write correct
implementations if you remove extraneous features. Ease of
interoperability is more important than aesthetic or compactness. If
you want something convenient for humans you should implement YAML,
but good luck writing a correct parser for that in a reasonable amount
of time ;)

> The first form seems more natural for an Erlang programmer, and if JSON
> BIF parser is included in the OTP, perhaps a customization to support
> this variant of the format would be a worthwhile addition as most
> frequently JSON is used for interaction with browsers that happily
> accept the first, more compact, form.

That's just a bad idea. If you intend to do that, don't call it JSON
because it's not. Not every JSON client is a JavaScript interpreter
using eval(). Actually mochijson/mochijson2 isn't even used at Mochi
Media to speak directly to a browser (outside of some internal tools),
it's used to communicate with other spec JSON implementations (e.g. in
ActionScript 2, ActionScript 3, or Python).

-bob



More information about the erlang-questions mailing list