[erlang-questions] fast JSON parser in C

Richard A. O'Keefe ok@REDACTED
Fri Jul 25 06:42:32 CEST 2008


On 25 Jul 2008, at 4:20 pm, Chris Anderson wrote:
> http://mail-archives.apache.org/mod_mbox/incubator-couchdb-dev/200807.mbox/%3ce282921e0807200924k256685f6r4b5651219f16d7b5@mail.gmail.com%3e

OK, the biggest question I see there is what to do about "objects".
It seemed intuitively obvious to me (is there a common abbreviation for
this (:-)?) that it would be really nice if a JSON "object" had an
Erlang representation that an Erlang programmer would normally use
for that kind of stuff.  So I expect
	{"foo":1, "bar":2}
to become
	[{foo,1},{bar,2}]
-- though there is a "security" option in the EEP to force
	[{<<"foo">>,1},{<<"bar">>,2}]
and the only major question in my mind was whether it should be sorted,
so that you can give one to orddict.

I see Joe recommends using a tuple, which has several merits:
  - all "objects" turn into the same kind of Erlang term
    (my proposal turns "{}" into {} but other objects into lists)
  - the brackets are the same in JSON and Erlang, always
  - I have to leave in a few minutes, you can think of others
It also has some downsides:
  - you can't pass it to orddict, but then, it would not be beyond
    human power to write an ordtuple module to do orddict-ish
    things
  - it's hard to process in other ways, although my EEP about
    allowing [Expr || Pattern {<-} Tuple] would make it _look_ easier.
  - it's just not what Erlang programmers normally use.
  - others I'm sure you can think of.

An interesting design problem.

--
If stupidity were a crime, who'd 'scape hanging?










More information about the erlang-questions mailing list