(text json) -- JSON parser

Library (text json)

This library provides JSON parser and writer.

Parameter *json-map-type*

Controls mapping of JSON map and array. The value must be either 'vector or 'alist. The first one is compatible with Chicken Scheme's json module, the latter one is compatible with Gauche's rfc.json module. By default, it's set to vector for backward compatibility.

Conversion rules for vector:

JSON array   <-> list
JSON map     <-> vector
JSON boolean <-> boolean
JSON null    <-> symbol `null`

Conversion rules for alist:

JSON array   <-> vector
JSON map     <-> alist
JSON boolean <-> boolean
JSON null    <-> symbol `null`

This parameter affects the read and write procedures.

Function json-read :optional ( port (current-input-port) )

Reads JSON from given port and returns representing S-expression.

Function json-write json :optional ( port (current-output-port) )

Writes the given S-expression JSON representing object to given port.

Function json-write/normalized json :optional ( port (current-output-port) )

Writes the given S-expression JSON representing object to given port.

The written JSON doesn't have excess space.

Function json-read-error? obj
Function json-write-error? obj

Returns #t if the given obj is &json-read or &json-write respectively, otherwise #f.