package b0
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=e9aa779e66c08fc763019f16d4706f465d16c05d6400b58fbd0313317ef33ddea51952e2b058db28e65f7ddb7012f328c8bf02d8f1da17bb543348541a2587f0
doc/b0.std/B0_json/Json/index.html
Module B0_json.Json
Source
JSON text
The type for text locations.
and t = [
| `Null of loc
| `Bool of bool * loc
| `Float of float * loc
| `String of string * loc
| `A of t list * loc
| `O of mem list * loc
]
The type for generic JSON text representations.
Constructors
Accessors
to_null j
extracts a null from j
. If j
is not a null an error with the location formatted according to Tloc.pp
is returned.
to_bool j
extracts a bool from j
. If j
is not a bool an error with the location formatted according to Tloc.pp
is returned.
to_float j
extracts a float from j
. If j
is not a float an error with the location formatted according to Tloc.pp
is returned.
to_array j
extracts a array from j
. If j
is not a array an error with the location formatted according to Tloc.pp
is returned.
to_obj j
extracts a array from j
. If j
is not a array an error with the location formatted according to Tloc.pp
is returned.
get_null j
is like to_null
but raises Invalid_argument
if j
is not a null.
get_bool j
is like to_bool
but raises Invalid_argument
if j
is not a bool.
get_float j
is like to_float
but raises Invalid_argument
if j
is not a float.
get_string j
is like to_string
but raises Invalid_argument
if j
is not a string.
get_array j
is like to_array
but raises Invalid_argument
if j
is not a array.
get_obj j
is like to_obj
but raises Invalid_argument
if j
is not a array.
Formatters
pp
formats JSON text.
Warning. Assumes all OCaml strings in the formatted value are UTF-8 encoded.
Codec
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. - TODO Unicode escapes are left unparsed (this will not round trip with
to_string
).
Note. All OCaml strings returned by this function are UTF-8 encoded.