package jsonxt

  1. Overview
  2. Docs

Json types for the various compliance levels

type json = [
  1. | `Null
  2. | `Bool of bool
  3. | `Int of int
  4. | `Intlit of string
  5. | `Float of float
  6. | `Floatlit of string
  7. | `String of string
  8. | `Stringlit of string
  9. | `Assoc of (string * json) list
  10. | `List of json list
  11. | `Tuple of json list
  12. | `Variant of string * json option
]

The following is a complete list of the polymorphic variants supported by Jsonxt

  • `Null: JSON null
  • `Bool of bool: JSON boolean
  • `Int of int: JSON number without decimal point or exponent.
  • `Intlit of string: JSON number without decimal point or exponent, preserved as a string.
  • `Float of float: JSON number, inf, -inf, Infinity, -Infinity, nan, -nan, NaN or -NaN
  • `Floatlit of string: JSON number, inf, -inf, Infinity, -Infinity, nan, -nan, NaN or -NaN, preserved as a string.
  • `String of string: JSON string. Bytes in the range 128-255 are preserved when reading and writing.
  • `Stringlit of string: JSON string literal including the double quotes.
  • `Assoc of (string * json) list: JSON object.
  • `List of json list: JSON array.
  • `Tuple of json list: Tuple (non-standard extension of JSON). Syntax: ("abc", 123).
  • `Variant of (string * json option): Variant (non-standard extension of JSON). Syntax: <"Foo"> or <"Bar":123>.
type t = json
module Extended : sig ... end

Extended supports all Json types including the non-standard tuple and variant introduced by Yojson

module Basic : sig ... end

Basic supports standard Json types that are supported by the JSON standard but also supports integers rather than just floats

module Strict : sig ... end

Strict supports only types that are supported by the JSON standard. Integers are not supported