Page
Library
Module
Module type
Parameter
Class
Class type
Source
Ezjsonm
SourceAn easy interface on top of the Jsonm
library.
This version provides more convenient (but far less flexible) input and output functions that go to and from string
values. This avoids the need to write signal code, which is useful for quick scripts that manipulate JSON.
More advanced users should go straight to the Jsonm
library and use it directly, rather than be saddled with the Ezjsonm interface below.
type value = [
| `Null
| `Bool of bool
| `Float of float
| `String of string
| `A of value list
| `O of (string * value) list
]
JSON fragments.
wrap v
wraps the value v
into a JSON array. To use when it is not possible to statically know that v
is a value JSON value.
unwrap t
is the reverse of wrap
. It expects t
to be a singleton JSON object and it return the unique element.
Read a JSON document from an input channel.
Write a JSON document to an output channel.
Write a JSON document to a string. This goes via an intermediate buffer and so may be slow on large documents.
Low-level function to write directly to a Jsonm
destination.
Build a triple.
All the following accessor functions expect the provided JSON document to be of a certain kind. In case this is not the case, Parse_error
is raised.
Extract the elements from a dictionnary document.
Extract the triple.
Find the sub-document adressed by the given path. Raise Not_found
if the path is invalid.
Update the sub-document addressed by the given path. If the provided value is None
, then removes the sub-document.
Apply a given function to a subdocument.
Convert a (possibly non-valid UTF8) string to a JSON object.
Convert a JSON object to a (possibly non-valid UTF8) string. Return None
if the JSON object is not a valid string.
Convert a JSON object to a (possibly non-valid UTF8) string.
Convert a JSON fragment to an S-expression.
An alias of to_sexp
Convert a JSON object to an S-expression
Convert an S-expression to a JSON fragment
AN alias of of_sexp
Convert an S-expression to a JSON object