Jsont_brrJavaScript 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.
val decode : 'a Jsont.t -> Jstr.t -> ('a, Jv.Error.t) Stdlib.resultdecode t s decodes the JSON data s according to t.
val decode' : 'a Jsont.t -> Jstr.t -> ('a, Jsont.Error.t) Stdlib.resultdecode' t s is like decode but preserves the error structure.
val decode_jv : 'a Jsont.t -> Jv.t -> ('a, Jv.Error.t) Stdlib.resultdecode_jv t v decodes the JavaScript value v according to t.
val decode_jv' : 'a Jsont.t -> Jv.t -> ('a, Jsont.Error.t) Stdlib.resultdecode_jv' is like decode_jv' but preserves the error structure.
val encode :
?format:Jsont.format ->
'a Jsont.t ->
'a ->
(Jstr.t, Jv.Error.t) Stdlib.resultencode 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.
val encode' :
?format:Jsont.format ->
'a Jsont.t ->
'a ->
(Jstr.t, Jsont.Error.t) Stdlib.resultencode' 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.
val encode_jv : 'a Jsont.t -> 'a -> (Jv.t, Jv.Error.t) Stdlib.resultencode_jv t v encodes v to a JavaScript value according to t.
val encode_jv' : 'a Jsont.t -> 'a -> (Jv.t, Jsont.Error.t) Stdlib.resultencode_jv' is like encode_jv but preserves the error structure.
val recode :
?format:Jsont.format ->
'a Jsont.t ->
Jstr.t ->
(Jstr.t, Jv.Error.t) Stdlib.resultval recode' :
?format:Jsont.format ->
'a Jsont.t ->
Jstr.t ->
(Jstr.t, Jsont.Error.t) Stdlib.resultval recode_jv : 'a Jsont.t -> Jv.t -> (Jv.t, Jv.Error.t) Stdlib.resultval recode_jv' : 'a Jsont.t -> Jv.t -> (Jv.t, Jsont.Error.t) Stdlib.resultrecode is decode_jv' followed by encode_jv'.