JSON
json?
read
write
json->string
string->json

JSON

by Dave Herman (dherman at ccs dot neu dot edu)

This library provides utilities for marshalling and unmarshalling data in the JSON data exchange format. See the JSON web site for more information about JSON.

The data structures of this library are immutable.

 (require (planet dherman/json:2:0))

This library uses the following Scheme representation of JSON data:

 

json

 ::= 

object  |  array  |  number  |  string  |  boolean  |  null

 

object

 ::= 

(hashof symbol? json)

 

array

 ::= 

(listof json)

 

number

 ::= 

integer?  |  inexact-real?

 

string

 ::= 

string?

 

boolean

 ::= 

boolean?

 

null

 ::= 

void?

(json? x)  boolean?
  x : any
Performs a deep check to determine whether x is a JSON value, i.e., a Scheme value following the grammar for the ‹json› non-terminal above.

(read [in])  json?
  in : input-port? = (current-input-port)
Reas a JSON value from input port in.

(write x [out])  any
  x : json?
  out : output-port? = (current-output-port)
Writes the JSON value x to output port out.

(json->string x)  string?
  x : json?
Generates a JSON source string for the JSON value x.

(string->json s)  json?
  s : string?
Parses the JSON string s as a JSON value.