The JSON structure


structure JSON


datatype value
  = OBJECT of (string * value) list
  | ARRAY of value list
  | NULL
  | BOOL of bool
  | INT of
  | FLOAT of real
  | STRING of string


datatype value = …​

This datatype represents JSON values as trees. The constructors are

OBJECT of (string * value) list

represents a JSON object value; i.e., a list of key-value pairs. Note that the keys should be unique.

ARRAY of value list

represents a JSON array value.


represents the JSON value "null".

BOOL of bool

represents the JSON values "true" and "false".

INT of

represents JSON integer numbers.

FLOAT of real

represents JSON floating-point numbers.

STRING of string

represents JSON strings, which are assumed to be UTF-8 encoded.


The JSON value

{ "a" : 23,
  "b" : [ false, true ],
  "c" : "hello world"

has the following representation using the value datatype:

  ("a", INT 23),
  ("b", ARRAY[BOOL false, BOOL true]),
  ("c", STRING "hello world")