json.lsp
Module: Json
Author: Jeff Ober
Version: 2.0
Original location: http://static.artfulcode.net/newlisp/json.lsp
Source: json.lsp
Package definition: json.qwerty
JSON parser and encoder; requires util.lsp (updated for newlisp 10)
Library for parsing JSON data and serializing lisp into JSON.
Version history
2.0 • completely rewrite of decoder (thanks to Andrew Pennebaker for pointing out the bugs in the original)
1.2 • fixed incompatibilities with newlisp 10
1.1 • added simple escape routine to outputted string values
1.0 • initial release- § -
Json:lisp->json
syntax: (Json:lisp->json expr)
parameter: expr - expression to be converted to JSON
Converts expression expr to JSON. Association lists and contexts are converted into objects. Other lists and arrays are converted into JSON arrays.
example:(Json:lisp->json '((a 1) (b 2))) => "{ 'A': 1, 'b': 2 }" (Json:lisp->json '(1 2 3 4 5)) => "[1, 2, 3, 4, 5]"- § -
Json:json->lisp
syntax: (Json:json->lisp str-json)
parameter: str-json - a valid JSON string
Parses a valid JSON string and returns a lisp structure. Arrays are converted to lists and objects are converted to assocation lists.
example:(Json:json->lisp "[1, 2, 3, 4]") => (1 2 3 4) (Json:json->lisp "{ 'x': 3, 'y': 4, 'z': [1, 2, 3] }") => (("x" 3) ("y" 4) ("z" (1 2 3)))- ∂ -
Artful Code
generated with newLISP and newLISPdoc