package jsonxt
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=71eb44d6e6deefa4b3ba7595d22f8e684ffb686c6a306679489c4e09779ee96b
sha512=4ca7c252d8cd3d3eb39f8094d16c7e1b14968ab61b314c1937248209785bedf434c2b422eb5961d896a41cd70565f9675f11f26b2ccc4e1e34c30260eed5d97b
doc/jsonxt/Jsonxt/Strict/index.html
Module Jsonxt.StrictSource
Strict supports parsing and writing JSON data that conforms to the Json.Strict.json json type. This only supports types supported by the JSON standard and explicity excludes integers. However, when encoded in floats integers in the range (+/-)2^53 have no loss of precision
Reader functions
Reader_string_file supports functions to parse JSON data from various sources. The interface includes two type of parser
- Single value parsers that return a single Json tree
json Stream.tfunctions that process a stream of JSON data, possibly seperated by whitespace. eg.{"a": 1} {"b":2}would result in 2 Json values being returned by the stream
json_of_string string converts string to a json value returing an error if the string has syntax, grammar or compliance errors
json_of_string_exn string converts string to a json value raising a Failure exception if the string has syntax, grammar or compliance errors
json_of_file file converts the text from file to a json value returing an error if the file contents have syntax, grammar or compliance errors. The file is closed on error
json_of_file file converts the text from file to a json value raising a Failure exception if the file contents have syntax, grammar or compliance errors. The file is closed on error
json_of_channel channel converts the text from channel to a json value returing an error if the channel contents have syntax, grammar or compliance errors. The channel is not closed
json_of_channel channel converts the text from channel to a json value raising a Failure exception if the channel contents have syntax, grammar or compliance errors. The file is not closed
json_of_function f converts text provided by f to a json value returing an error if the supplied text has syntax, grammar or compliance errors. The function f buf len takes a bytes buf buffer, the maximum number of bytes to read len and returns the number of bytes read. Returning 0 indicates end-of-file
json_of_function_exn f converts text provided by f to a json value raising a Failure exception if the channel contents have syntax, grammar or compliance errors. See json_of_function for detail of function f
json_of_lexbuf lexbuf converts text in the supplied lexbuf to a json value returning an error if the supplied text has syntax, grammar or compliance errors. This is a low level function and json_of_function should be used in preference
json_of_lexbuf_exn lexbuf converts text in the supplied lexbuf to a json value raising a Failure exception if the supplied text has syntax, grammar or compliance errors. This is a low level function and json_of_function_exn should be used in preference
of_channel is an alias for json_of_channel_exn
of_function is an alias for json_of_function_exn
Error_info.t returning functions
The following functions are identical to the functions without the _error_info extension except they return an (json, Error_info.t) result instead of a (json, string) result. See Jsonxt.Error_info for details of of Error_info.t
compatablity functions for internal use
val json_of_lexbuf_error_info_compat :
?stream:bool ->
Lexing.lexbuf ->
(json option, Error_info.t) resultStream.t readers
Stream.t readers provide a mechanism to read a stream of JSON values. eg
{"datapoint": 1, "value": 2}
{"datapoint": 2, "value": 5}stream_from_string string converts string containing zero or more json object to a json Stream.t value raising a Failure exception if the string has syntax, grammar or compliance errors
stream_from_channel in_channel converts the text from in_channel, containing zero or more json objects, to a json Stream.t value raising a Failure exception if the file has syntax, grammar or compliance errors. The optional parameter fin specifies a function to call when all json objects have been returned or a failure occurs
stream_from_file filename converts the text from file filename, containing zero or more json objects, to a json Stream.t value raising a Failure exception if the file has syntax, grammar or compliance errors
stream_from_function f converts text provided by f, containing zero of more JSON objects, to a json Stream.t value raising a Failure exception if the file has syntax, grammar or compliance errors. The function f buf len takes a buf buffer to fill, the maximum number of bytes to read len and returns the number of bytes read. Returning 0 indicates end-of-file
stream_from_file lexbuf converts the text from lexbuf, containing zero or more json objects, to a json Stream.t value raising a Failure exception if the file has syntax, grammar or compliance errors. This is a low level function and stream_from_function should be used in preference
Error_info.Json_error_info raising Stream.t functions
The following functions are identical to the functions without the _error_info extension except they raise an Error_info.Json_error_info Error_info.t exception instead of a Failure string. See Jsonxt.Error_info for details of the exception
Writer functions
json_to_string json converts json to a string, returning an error if the json value contains data that fails compliance checks
json_to_string_exn json converts json to a string, raising a Failure excepion if the json value contains data that fails compliance checks
to_string is an alias for json_to_string_exn
json_to_string_hum json converts json to a string in human readable format, returning an error if the json value contains data that fails compliance checks
json_to_string_hum_exn json converts json to a string in human readable format, raising a Failure excepion if the json value contains data that fails compliance checks
to_string_hum is an alias for json_to_string_hum_exn
json_to_file file json converts json to a string and writes it to file, returning an error if the json value contains data that fails compliance checks. The file will be closed on error.
json_to_file_hum file json converts json to a string in human readable format and writes it to file, returning an error if the json value contains data that fails compliance checks. The file will be closed on error.
json_to_file_exn file json converts json to a string and writes it to file, raising a Failure exception if the json value contains data that fails compliance checks. The file will be closed on error.
json_to_file_hum_exn file json converts json to a string in human readable format and writes it to file, raising Failure exception if the json value contains data that fails compliance checks. The file will be closed on error.
json_to_channel channel json converts json to a string and writes it to channel, returning an error if the json value contains data that fails compliance checks. The channel is not closed.
json_to_channel_exn channel json converts json to a string and writes it to channel, raising a Failure exception if the json value contains data that fails compliance checks. The channel will be closed on error.
json_to_channel_hum channel json converts json to a string in human readable format and writes it to channel, returning an error if the json value contains data that fails compliance checks. The channel is not closed.
json_to_channel_hum_exn channel json converts json to a string in human readable format and writes it to channel, raising Failure exception if the json value contains data that fails compliance checks. The channel is not closed
to_file is an alias for json_to_file_exn
to_file_hum is an alias for json_to_file_hum_exn
to_channel is an alias for json_to_channel_exn
to_channel_hum is an alias for json_to_channel_hum_exn
json_to_buffer buf json converts and outputs json to the supplied buf, returning an error if the json value contains data that fails compliance checks.
json_to_buffer_exn buf json converts and outputs json to the supplied buf, raising a Failure exception if the json value contains data that fails compliance checks.
json_to_buffer_hum buf json converts and outputs json in a human readable format to the supplied buf, returning an eror if the json value contains data that fails compliance checks.
json_to_buffer_hum_exn buf json converts and outputs json in a human readable format to the supplied buf, raising a Failure exception if the json value contains data that fails compliance checks.
to_buffer is an alias for json_to_buffer_exn
to_buffer_hum is an alias for json_to_buffer_hum_exn
pretty_print out json pretty prints the json tree to the Formater.formatter The output is more compact than the _hum versions but still readable
pretty_print_to_string json converts the json tree into a pretty printed string. The output is more compact than the _hum versions but still readable
pretty_print oc json pretty prints the json tree to the output channel out The output is more compact than the _hum versions but still readable
stream_to_string stream converts a Stream.t of json values to a string, separating the enties with newlines
stream_to_channel out_channel converts a Stream.t of json values to a newline separated list of compact json strings and outputs them to out_channel
stream_to_file stream file converts a Stream.t of json values to a newline separated list of compact json strings and outputs them to file
stream_to_buffer buf stream converts a Stream.t of json values to compact strings and outputs them, separating by newlines, to buf
Processing functions
Strict supports processing JSON data that conforms to the Json.Strict.json json type.