You are looking at historical revision 25894 of this page. It may differ significantly from its current revision.
A JSON reader and writer based on the genturfa'i parsing library. It's not quite as fast as the alternative json and json-abnf eggs but other than those its representation of JSON data types in Scheme can be fully customized. It's also possible to change how and what Scheme data types are serialized to JSON.
UTF-8 encoded Unicode characters outside the ASCII range in strings are currently not supported. This is due to a limitation in genturfa'i and will hopefully be addressed soon.
Documentation[parameter] (json-parsers [parsers])
An alist which maps JSON data type symbols to procedures which are used to convert the corresponding data types to Scheme data structures. By default the following mappings apply:
- pair (keys are represented as symbols)
- list of member pairs
An alist which maps predicate functions to emitter functions. When a datum is to be written the predicates are tried in order until one returns #t. The datum is passed to the corresponding emitter function which is expected to write its JSON representation to (current-output-port). By default the following mappings apply:
- object (an alist with symbols for keys is expected)
- (lambda (x) (eq? x #t))
- (lambda (x) (eq? x #f))
- (lambda (x) (eq? x 'null))
Reads a JSON document from port-or-string which is (current-input-port) by default according to the current json-parsers.[procedure] (write-json datum [port])
Writes the given JSON datum to port which is (current-output-port) by default according to the current (json-unparsers).[procedure] (json->string datum)
Returns a string containing the JSON representation of the given datum according to the current (json-unparsers).
Copyright (C) 2011 Moritz Heidkamp All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the <organization> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.