Module Misc.Json
JSON utilities
Simple (and not very robust) JSON generation utilities.
Everything is string based, creating lots of intermediate strings. Moreover, Json.string uses a custom string encoding based on the code for the format specifier %S, but with escapes for \u00HH instead of OCaml's \DDD.
val field : string -> string -> stringfield name value creates a JSON field with the given name and value.
val string : string -> stringstring value formats a string value as a JSON string.
int value formats an integer value as a JSON number.
val float : float -> stringfloat value formats a float value as a JSON number.
val object_ : string list -> stringobject_ fields creates a JSON object from a list of field strings.
val array : string list -> stringarray items creates a JSON array from a list of item strings.
null is the JSON null literal.
val option : ('a -> string) -> 'a option -> stringoption f opt formats an optional value as JSON. Returns the JSON null literal for None, or applies f to the value for Some v.