= The JSON Library
:Author: John Reppy
:Date: {release-date}
:stem: latexmath
:source-highlighter: pygments
:VERSION: {smlnj-version}

== Overview
The *JSON Library* provides operations on the datatype representation
of https://www.json.org/json-en.html[*JSON* (JavaScript Object Notation)]
values.  The datatype representation is defined in the xref:../Util/str-JSON.adoc[`JSON`]
structure, which is part of the xref:util-lib.adoc[the __Util Library__].
This library provides support for parsing, printing, and manipulating *JSON*
values as trees.  There is also support for processing *JSON* data as
streams using a "SAX-style" API.

== Contents

=== Tree-based API

  xref:str-JSONParser.adoc[`[.kw]#structure# JSONParser`]::
    A parser for *JSON* input.

  xref:str-JSONPrinter.adoc[`[.kw]#structure# JSONPrinter`]::
    A printer for *JSON* output.

  xref:str-JSONUtil.adoc[`[.kw]#structure# JSONUtil`]::
    A collection of utility functions for working with *JSON* values.

  xref:str-JSONDecode.adoc[`[.kw]#structure# JSONDecode`]::
    A collection of combinators for decoding *JSON* values.

=== Stream-based API

  xref:str-JSONStreamParser.adoc[`[.kw]#structure# JSONStreamParser`]::
    A stream (or event) based parser for JSON input.

  xref:sig-JSON_STREAM_OUTPUT.adoc[`[.kw]#signature# JSON_STREAM_OUTPUT`]::
    The interface to a stream-based printer for JSON output.

  xref:str-JSONBufferPrinter.adoc[`[.kw]#structure# JSONBufferPrinter`]::
    A stream-based printer for JSON output to character buffers.

  xref:str-JSONStreamPrinter.adoc[`[.kw]#structure# JSONStreamPrinter`]::
    A stream-based printer for JSON output to text files.

== Usage

For https://smlnj.org[*SML/NJ*], include `$/json-lib.cm` in your
*CM* file.

For use in https://www.mlton.org/[*MLton*], include
`$(SML_LIB)/smlnj-lib/JSON/json-lib.mlb` in your *MLB* file.

ifdef::backend-pdf[]

// Push titles down one level.
:leveloffset: 1

include::str-JSONParser.adoc[]

include::str-JSONPrinter.adoc[]

include::str-JSONUtil.adoc[]

include::str-JSONDecode.adoc[]

include::str-JSONStreamParser.adoc[]

include::sig-JSON_STREAM_OUTPUT.adoc[]

include::str-JSONBufferPrinter.adoc[]

include::str-JSONStreamPrinter.adoc[]

// Return to normal title levels.
:leveloffset: 0

endif::[]
