[cl-json-devel] Newbie to Lisp question, trying to create JSON

Henrik Hjelte henrik at evahjelte.com
Tue Apr 12 07:42:18 UTC 2011


>> On Thu, Apr 7, 2011 at 4:07 PM, Jim Barrows <jim.barrows at gmail.com> wrote:
>>>
>>> I'm trying to encode a list of plists, and encode-json-plist-to-string
>>> doesn't appear to do it.
>>
>> Yes, because the first list is a list and not a plist.
>
>
> Am I incorrect in thinking this is a list of plists?  I'm still in shock
> over the difference in terminology between Java and Lisp...

And I am often shocked when I need to do various things in the Java
world, so I understand your reaction.

No your right, it is a list of p-lists. But the encode-json-plist
function is for p-lists, not necessarily lists of p-lists. It is an
easy way to render a simple key-value object. Probably not the best
choice if you want to have control over details, then I suggest the
explicit encoder.

The problem is for the encoder to guess what you intend to have as
output. A p-list looks just like a list, so what do you want as
output, an object or a list? How should a nested list  (one of the
values in the key-value pair) that looks like a p-list be converted,
to a json-list or a json-object?

It is slightly easier with a-lists, I think you will get a list of
objects if you have a list of a-lists and encode-json-alist.

Or if you don't like the unpredictable ways of some code trying to
guess what you want, just use the explicit encoder or the streaming
encoder, then you have full control. Look at the testcases for lots of
examples.

/Henrik




More information about the cl-json-devel mailing list