[cl-json-devel] proposed: improvements to decoder customization

Hans Hübner hans at huebner.org
Sun Aug 3 23:58:46 UTC 2008


On Sun, Aug 3, 2008 at 15:14, Henrik Hjelte <henrik at evahjelte.com> wrote:

> Any other wishes?

I don't quite like the serialization mechanism that cl-json provides.
The attempt to map from a Lisp datatype to a certain json structure is
necessarily imperfect because no 1:1 relationship exists, and the
requirement to first make up a data structure and then call
encode-json to convert it to a json string is wasteful.

A streaming serialization API is more useful, as one has more control
over the json format that is being generated and the need to make up a
data structure that can uniquely be mapped to json structures is
removed.  It is inspired by CXML's streaming serialization which I
find very easy and straightforward to use.

I have written something that allows my application code to use a
similar scheme, see
http://bknr.net/trac/browser/trunk/projects/quickhoney/src/handlers.lisp?rev=3723#L437
- The implementation of the json serializer is in
http://bknr.net/trac/browser/trunk/projects/quickhoney/src/json.lisp,
but it is kind of hackish because it tries to reuse some of cl-json's
serialization facilities for atomic types and jumps some hoops to make
the correct separators between serialized elements be generated.

This could certainly be improved, yet it works for me and I'd be glad
to see this or a similar mechanism be integrated into cl-json.

-Hans



More information about the cl-json-devel mailing list