Initial release of a JSON module

Started by Lutz, March 21, 2010, 07:27:31 AM

Previous topic - Next topic

Lutz

The initial release of a JSON module can be found here:



http://www.newlisp.org/modules/various/json.lsp.html">http://www.newlisp.org/modules/various/json.lsp.html



also linked from the "Various" section on the main modules index:



http://www.newlisp.org/modules/">http://www.newlisp.org/modules/



The module is based on the JSON code from the Tips&Tricks section but with the missing true,false and null -keywords added. The code is also a typical example how to write parsers and code translators in newLISP.

itistoday

#1
Cool! Are you planning to update it with an 'expr2json'? That would be quite handy...
Get your Objective newLISP groove on.

Lutz

#2
Currently in 'json2expr', sequences and arrays, both are translated into normal lists, which for practical purposes in most real world cases is good enough. But for large JSON arrays of e.g. thousands of elements, a translation of JSON arrays into newLISP arrays would be superior, and would not create the ambiguity when back translating wirth the future 'expr2json'.



The next version 0.2 will introduce a 'true' flag as in (json2expr json-text true) and will translate JSON arrays into newLISP arrays when the flag is present, then a back-translation with 'expr2json' doesn't have the ambiguity problem. The 'expr2json' function could carry the same flag.



Most people (including I) use newLISP arrays rarely, so the current simple way of doing it seems adequate as a start.