A JSON Library for Common Lisp

JSON                        Lisp
123                         123
123.0                       123d0
"foo"                       "foo"
true                        :TRUE
false                       :FALSE
null                        :NULL
[1, 2, 3, 4]                #(1 2 3 4)
{ "x": 1, "y": 2 }          (:X 1 :Y 2)
{ "fooBar": 0 }             (:FOO-BAR 0)
{ "foo-bar": 0 }            (:FOO--BAR 0)


read-json  stream &key camel-escape-char max-nest interactive-p

Reads JSON from the stream stream, which must be a character input stream.

max-nest is the maximum nesting of objects and arrays allowed. It defaults to *json-max-nest*. When this nesting level is exceeded a json-parse-error is signaled.

The interactive-p parameter defaults to (stream-interactive-p stream).

If interactive-p is NIL, the stream is assumed to be non-interactive. It is then assumed and checked, that the stream contains exactly one JSON object followed by optional whitespace and end-of-file.

If interactive-p is non-NIL, the stream is assumed to be interactive. Then reading stops after one JSON element is parsed. The input directly following the JSON element is left for further reading. White space is preserved.

parse-json  string &key start end camel-escape-char max-nest interactive-p

Parses JSON from the string string.

The max-nest parameter is as for read-json.

Special variable

The default for the :max-nest parameter to read-json and parse-json.


print-json  object stream

Gilbert Baumann,