package cow
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Module Cow.JsonSource
JSON (JavaScript Object Notation) library
include module type of Ezjsonm
Basic types
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.
Reading JSON documents and values
Read a JSON document from an input channel.
Read a JSON value from an input channel.
Low-level function to read directly from a Jsonm source.
Reading JSON documents and values -- with proper errors
Error locations in a source document follow the Jsonm representation of pairs of pairs ((start_line, start_col), (end_line, end_col)) with 0-indexed lines and 1-indexed columns.
type read_value_error = [ | `Error of error_location * Jsonm.error| `Unexpected of [ `Lexeme of error_location * Jsonm.lexeme * string | `End_of_input ]
]A human-readable description of an error -- without using the error location.
If the error is attached to a specific location in the buffer, return this location.
See from_channel.
See from_string.
See value_from_channel.
See value_from_string.
See value_from_src.
Writing JSON documents and values
Write a JSON document to an output channel.
Write a JSON value to an output channel.
Write a JSON value to a buffer.
Write a JSON value 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.
Constructors
Build a triple.
Accessors
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.
High-level functions
mem v path is true if the given path is valid for the JSON document v.
Find the sub-document addressed by the given path. Raise Not_found if the path is invalid.
Find the sub-document addressed by the given path. Returns None 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.