[erlang-questions] JSON encoding of arrays of arrays

Rapsey rapsey@REDACTED
Fri Oct 22 11:12:48 CEST 2010


On Fri, Oct 22, 2010 at 10:54 AM, Alessandro Sivieri <
alessandro.sivieri@REDACTED> wrote:

> 2010/10/22 Bob Ippolito <bob@REDACTED>
>
> > I'm surprised that people are finding it to be complicated. A list of
> > lists is literally an erlang list with erlang lists in it. It looks
> > like the documentation does need some improvement though, it's only
> > really obvious if you use it or if you read through the data types.
> >
> >
> Well, maybe the documentation of mochijson2 is not *that* good (no offense
> here), I mean a couple of examples should be added I think. Also, the best
> API would be the one that takes the standard Erlang types (for example a
> list of lists) and produces a json, without the "struct" thing; I think
> there was a project like that somewhere on the Net, but it did not work
> with
> tuples...
>

It is actually very easy to change mochijson2 module not to produce
{struct,...} for decode (it's what I do). Encoding works without it as well.
The only problem with encoding is when to interpret something as an array or
object. mochijson2 supports explicitly specifying {array,[...]} as well as
{struct,[..]}.


Sergej


More information about the erlang-questions mailing list