The JSON structure
Author: John Reppy
Keywords: Standard ML, SML, SML/NJ Library

The SML of NJ Library
The `JSON` structure

## Synopsis

    structure JSON

## Interface

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

## Description

`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.

  `NULL`

    represents the JSON value `"null"`.

  `BOOL of bool`

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

  `INT of IntInf.int`

    represents JSON integer numbers.

  `INTLIT of string`

    represents JSON integer numbers that have a large number of digits.

  `FLOAT of real`

    represents JSON floating-point numbers.

  `STRING of string`

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

## Example

The JSON value

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

has the following representation using the value datatype:

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

## See Also

`JSONUtil`, The JSON Library

SML/NJ Version 110.99.7 (December 28, 2024)
Last updated 2024-12-27 20:35:08 UTC