package b0

  1. Overview
  2. Docs

JSON text codec.

Warning. The module assumes strings are UTF-8 encoded.

Generic JSON representation

type t = [
  1. | `Null
  2. | `Bool of bool
  3. | `Float of float
  4. | `String of string
  5. | `A of t list
  6. | `O of (string * t) list
]

The type for generic JSON text representations.

val of_string : string -> (t, string) result

of_string s parses JSON text from s according to RFC8259 with the following limitations:

  • Numbers are parsed with string_of_float which is not compliant.
  • Unicode escapes are left unparsed (this will not round trip with to_string).
val to_string : t -> string

to_string v is v as JSON text, encoded according to RFC8259

OCaml

Innovation. Community. Security.