Module B0_web.Json

JSON text codec.

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

Generic JSON representation

type t = [
| `Null
| `Bool of bool
| `Float of float
| `String of string
| `A of t list
| `O of (string * t) list
]

The type for generic JSON text representations.

val of_string : string -> (t, string) Stdlib.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