package jsont

  1. Overview
  2. Docs
Declarative JSON data manipulation for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

jsont-0.2.0.tbz
sha512=6206f73a66cb170b560a72e58f70b9fb2c20397b9ab819dceba49b6602b9b79e47ba307e6910e61ca4694555c66fdcd7a17490afb99548e8f43845a5a88913e7

doc/jsont.brr/Jsont_brr/index.html

Module Jsont_brrSource

JavaScript support.

Note. These functions incur a bit of overhead but should work fast enough for medium sized structures. Get in touch if you run into problems, some improvements may be possible.

The JSON functions use JavaScript's JSON.parse and JSON.stringify to convert to JavaScript values which are then converted with decode_jv and encode_jv. Parse locations and layout preservation are unsupported.

Decode

Sourceval decode : 'a Jsont.t -> Jstr.t -> ('a, Jv.Error.t) result

decode t s decodes the JSON data s according to t.

Sourceval decode' : 'a Jsont.t -> Jstr.t -> ('a, Jsont.Error.t) result

decode' t s is like decode but preserves the error structure.

Sourceval decode_jv : 'a Jsont.t -> Jv.t -> ('a, Jv.Error.t) result

decode_jv t v decodes the JavaScript value v according to t.

Sourceval decode_jv' : 'a Jsont.t -> Jv.t -> ('a, Jsont.Error.t) result

decode_jv' is like decode_jv' but preserves the error structure.

Encode

Sourceval encode : ?format:Jsont.format -> 'a Jsont.t -> 'a -> (Jstr.t, Jv.Error.t) result

encode t v encodes v to JSON according to t. format specifies how the JSON is formatted, defaults to Jsont.format.Minify. The Jsont.format.Layout format is unsupported, Jsont.format.Indent is used instead.

Sourceval encode' : ?format:Jsont.format -> 'a Jsont.t -> 'a -> (Jstr.t, Jsont.Error.t) result

encode' is like encode but preserves the error structure. format specifies how the JSON is formatted, defaults to Jsont.format.Minify. The Jsont.format.Layout format is unsupported, Jsont.format.Indent is used instead.

Sourceval encode_jv : 'a Jsont.t -> 'a -> (Jv.t, Jv.Error.t) result

encode_jv t v encodes v to a JavaScript value according to t.

Sourceval encode_jv' : 'a Jsont.t -> 'a -> (Jv.t, Jsont.Error.t) result

encode_jv' is like encode_jv but preserves the error structure.

Recode

Sourceval recode : ?format:Jsont.format -> 'a Jsont.t -> Jstr.t -> (Jstr.t, Jv.Error.t) result

recode is decode followed by encode.

Sourceval recode' : ?format:Jsont.format -> 'a Jsont.t -> Jstr.t -> (Jstr.t, Jsont.Error.t) result

recode is decode' followed by encode'.

Sourceval recode_jv : 'a Jsont.t -> Jv.t -> (Jv.t, Jv.Error.t) result

recode is decode followed by encode.

Sourceval recode_jv' : 'a Jsont.t -> Jv.t -> (Jv.t, Jsont.Error.t) result

recode is decode_jv' followed by encode_jv'.