JSON?

Jim Larson <>
Tue Nov 15 06:51:53 CET 2005


In message <> 
you write:
>I'll bet someone has implemented JSON
>(http://www.crockford.com/JSON/index.html) for Erlang, but it is not in
>the implementation list on the web site.
>
>If not, I'd welcome any comments on how to do it in Erlang, otherwise
>I'm sure to muck it up.

I've got an implementation; I'll see if I can get my company to
allow me to release it.

My library works with the following mapping:

	JSON Numbers    <==>     Erlang Numbers
        JSON Strings    <==>     Erlang Strings (lists of Unicode chars)
        JSON Arrays     <==>     Erlang Tuples
        JSON Objects    <==>     Erlang Dicts with String keys
        JSON bool, null <==>     Erlang Atoms 'true', 'false', 'null'

(The ambiguity that an Erlang dict is represented as a tuple is not
a problem, since the first element 'dict' is not a legal value for
encoding.)

It all works quite well, especially with Joe's middle man framework.
The only awkwardness is with the string keys for the decoded objects.
If the atom table were garbage collected, I'd use real atoms here.
I'd also rather have Richard O'Keefe's "dictionaries", proposed a
while back, rather than dicts, but it seems like the best available
choice for now.

Jim Larson




More information about the erlang-questions mailing list