Module Jsonxt.Extended
Extended supports parsing and writing JSON data that conforms to the Json.Extended.json json type. This supports non-standard JSON types including integer as well as tuples and variants introduced by Yojson.
The maximim/minimum size of an integer is architecture specific, typically 30 or 62 bits depending on the platform. In cases where the integer overflows the value is converted to a `Float. For integers in the range (+/-)2^53 there is no loss of precision
type json= Json.Extended.jsontype t= json
Reader functions
include Jsonxt__.Reader_string_file.Reader_string_file with type json := json
val json_of_string : string -> (json, string) Stdlib.resultjson_of_string stringconvertsstringto ajsonvalue returing an error if the string has syntax, grammar or compliance errors
val json_of_string_exn : string -> jsonjson_of_string_exn stringconvertsstringto ajsonvalue raising aFailureexception if the string has syntax, grammar or compliance errors
val json_of_file : string -> (json, string) Stdlib.resultjson_of_file fileconverts the text fromfileto ajsonvalue returing an error if the file contents have syntax, grammar or compliance errors. The file is closed on error
val json_of_file_exn : string -> jsonjson_of_file fileconverts the text fromfileto ajsonvalue raising aFailureexception if the file contents have syntax, grammar or compliance errors. The file is closed on error
val json_of_channel : Stdlib.in_channel -> (json, string) Stdlib.resultjson_of_channel channelconverts the text fromchannelto ajsonvalue returing an error if the channel contents have syntax, grammar or compliance errors. The channel is not closed
val json_of_channel_exn : Stdlib.in_channel -> jsonjson_of_channel channelconverts the text fromchannelto ajsonvalue raising aFailureexception if the channel contents have syntax, grammar or compliance errors. The file is not closed
val json_of_function : (bytes -> int -> int) -> (json, string) Stdlib.resultjson_of_function fconverts text provided byfto ajsonvalue returing an error if the supplied text has syntax, grammar or compliance errors. The functionf buf lentakes abytesbufbuffer, the maximum number of bytes to readlenand returns the number of bytes read. Returning 0 indicates end-of-file
val json_of_function_exn : (bytes -> int -> int) -> jsonjson_of_function_exn fconverts text provided byfto ajsonvalue raising aFailureexception if the channel contents have syntax, grammar or compliance errors. Seejson_of_functionfor detail of functionf
val json_of_lexbuf : Stdlib.Lexing.lexbuf -> (json, string) Stdlib.resultjson_of_lexbuf lexbufconverts text in the suppliedlexbufto ajsonvalue 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
val json_of_lexbuf_exn : Stdlib.Lexing.lexbuf -> jsonjson_of_lexbuf_exn lexbufconverts text in the suppliedlexbufto ajsonvalue raising aFailureexception 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
val of_string : string -> jsonof_stringis an alias for json_of_string_exn
val of_file : string -> jsonof_fileis an alias for json_of_file_exn
val of_channel : Stdlib.in_channel -> jsonof_channelis an alias for json_of_channel_exn
val of_function : (bytes -> int -> int) -> jsonof_functionis 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
val json_of_string_error_info : string -> (json, Error_info.t) Stdlib.resultval json_of_file_error_info : string -> (json, Error_info.t) Stdlib.resultval json_of_channel_error_info : Stdlib.in_channel -> (json, Error_info.t) Stdlib.resultval json_of_function_error_info : (bytes -> int -> int) -> (json, Error_info.t) Stdlib.resultval json_of_lexbuf_error_info : Stdlib.Lexing.lexbuf -> (json, Error_info.t) Stdlib.result
compatablity functions for internal use
val json_of_lexbuf_error_info_compat : ?stream:bool -> Stdlib.Lexing.lexbuf -> (json option, Error_info.t) Stdlib.result
Stream.t readers
Stream.t readers provide a mechanism to read a stream of JSON values. eg
{"datapoint": 1, "value": 2}
{"datapoint": 2, "value": 5}val stream_from_string : string -> json Stdlib.Stream.tstream_from_string stringconvertsstringcontaining zero or more json object to ajson Stream.tvalue raising aFailureexception if the string has syntax, grammar or compliance errors
val stream_from_channel : ?fin:(unit -> unit) -> Stdlib.in_channel -> json Stdlib.Stream.tstream_from_channel in_channelconverts the text fromin_channel, containing zero or more json objects, to ajson Stream.tvalue raising aFailureexception if the file has syntax, grammar or compliance errors. The optional parameterfinspecifies a function to call when all json objects have been returned or a failure occurs
val stream_from_file : string -> json Stdlib.Stream.tstream_from_file filenameconverts the text from filefilename, containing zero or more json objects, to ajson Stream.tvalue raising aFailureexception if the file has syntax, grammar or compliance errors
val stream_from_function : (bytes -> int -> int) -> json Stdlib.Stream.tstream_from_function fconverts text provided byf, containing zero of more JSON objects, to ajson Stream.tvalue raising aFailureexception if the file has syntax, grammar or compliance errors. The functionf buf lentakes abufbuffer to fill, the maximum number of bytes to readlenand returns the number of bytes read. Returning 0 indicates end-of-file
val stream_from_lexbuf : Stdlib.Lexing.lexbuf -> json Stdlib.Stream.tstream_from_file lexbufconverts the text fromlexbuf, containing zero or more json objects, to ajson Stream.tvalue raising aFailureexception 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
val stream_from_string_error_info : string -> json Stdlib.Stream.tval stream_from_channel_error_info : ?fin:(unit -> unit) -> Stdlib.in_channel -> json Stdlib.Stream.tval stream_from_file_error_info : string -> json Stdlib.Stream.tval stream_from_function_error_info : (bytes -> int -> int) -> json Stdlib.Stream.tval stream_from_lexbuf_error_info : Stdlib.Lexing.lexbuf -> json Stdlib.Stream.t
Writer functions
include Jsonxt__.Writer_intf.Intf with type json := Json.Extended.json
val json_to_string : json -> (string, string) Stdlib.resultjson_to_string jsonconvertsjsonto astring, returning an error if the json value contains data that fails compliance checks
val json_to_string_exn : json -> stringjson_to_string_exn jsonconvertsjsonto astring, raising aFailureexcepion if the json value contains data that fails compliance checks
val to_string : json -> stringto_stringis an alias for json_to_string_exn
val json_to_string_hum : json -> (string, string) Stdlib.resultjson_to_string_hum jsonconvertsjsonto astringin human readable format, returning an error if the json value contains data that fails compliance checks
val json_to_string_hum_exn : json -> stringjson_to_string_hum_exn jsonconvertsjsonto astringin human readable format, raising aFailureexcepion if the json value contains data that fails compliance checks
val to_string_hum : json -> stringto_string_humis an alias for json_to_string_hum_exn
val json_to_file : string -> json -> (unit, string) Stdlib.resultjson_to_file file jsonconvertsjsonto a string and writes it tofile, returning an error if the json value contains data that fails compliance checks. The file will be closed on error.
val json_to_file_hum : string -> json -> (unit, string) Stdlib.resultjson_to_file_hum file jsonconvertsjsonto a string in human readable format and writes it tofile, returning an error if the json value contains data that fails compliance checks. The file will be closed on error.
val json_to_file_exn : string -> json -> unitjson_to_file_exn file jsonconvertsjsonto a string and writes it tofile, raising aFailureexception if the json value contains data that fails compliance checks. The file will be closed on error.
val json_to_file_hum_exn : string -> json -> unitjson_to_file_hum_exn file jsonconvertsjsonto a string in human readable format and writes it tofile, raisingFailureexception if the json value contains data that fails compliance checks. The file will be closed on error.
val json_to_channel : Stdlib.out_channel -> json -> (unit, string) Stdlib.resultjson_to_channel channel jsonconvertsjsonto a string and writes it tochannel, returning an error if the json value contains data that fails compliance checks. The channel is not closed.
val json_to_channel_exn : Stdlib.out_channel -> json -> unitjson_to_channel_exn channel jsonconvertsjsonto a string and writes it tochannel, raising aFailureexception if the json value contains data that fails compliance checks. The channel will be closed on error.
val json_to_channel_hum : Stdlib.out_channel -> json -> (unit, string) Stdlib.resultjson_to_channel_hum channel jsonconvertsjsonto a string in human readable format and writes it tochannel, returning an error if the json value contains data that fails compliance checks. The channel is not closed.
val json_to_channel_hum_exn : Stdlib.out_channel -> json -> unitjson_to_channel_hum_exn channel jsonconvertsjsonto a string in human readable format and writes it tochannel, raisingFailureexception if the json value contains data that fails compliance checks. The channel is not closed
val to_file : string -> json -> unitto_fileis an alias for json_to_file_exn
val to_file_hum : string -> json -> unitto_file_humis an alias for json_to_file_hum_exn
val to_channel : Stdlib.out_channel -> json -> unitto_channelis an alias for json_to_channel_exn
val to_channel_hum : Stdlib.out_channel -> json -> unitto_channel_humis an alias for json_to_channel_hum_exn
val json_to_buffer : Stdlib.Buffer.t -> json -> (unit, string) Stdlib.resultjson_to_buffer buf jsonconverts and outputsjsonto the suppliedbuf, returning an error if the json value contains data that fails compliance checks.
val json_to_buffer_exn : Stdlib.Buffer.t -> json -> unitjson_to_buffer_exn buf jsonconverts and outputsjsonto the suppliedbuf, raising aFailureexception if the json value contains data that fails compliance checks.
val json_to_buffer_hum : Stdlib.Buffer.t -> json -> (unit, string) Stdlib.resultjson_to_buffer_hum buf jsonconverts and outputsjsonin a human readable format to the suppliedbuf, returning an eror if the json value contains data that fails compliance checks.
val json_to_buffer_hum_exn : Stdlib.Buffer.t -> json -> unitjson_to_buffer_hum_exn buf jsonconverts and outputsjsonin a human readable format to the suppliedbuf, raising aFailureexception if the json value contains data that fails compliance checks.
val to_buffer : Stdlib.Buffer.t -> json -> unitto_bufferis an alias for json_to_buffer_exn
val to_buffer_hum : Stdlib.Buffer.t -> json -> unitto_buffer_humis an alias for json_to_buffer_hum_exn
val pretty_print : Stdlib.Format.formatter -> json -> unitpretty_print out jsonpretty prints thejsontree to theFormater.formatterThe output is more compact than the _hum versions but still readable
val pretty_print_to_string : json -> stringpretty_print_to_string jsonconverts thejsontree into a pretty printed string. The output is more compact than the _hum versions but still readable
val pretty_print_to_channel : Stdlib.out_channel -> json -> unitpretty_print oc jsonpretty prints thejsontree to the output channeloutThe output is more compact than the _hum versions but still readable
val stream_to_string : json Stdlib.Stream.t -> stringstream_to_string streamconverts aStream.tofjsonvalues to a string, separating the enties with newlines
val stream_to_channel : Stdlib.out_channel -> json Stdlib.Stream.t -> unitstream_to_channel out_channelconverts aStream.tofjsonvalues to a newline separated list of compact json strings and outputs them toout_channel
val stream_to_file : string -> json Stdlib.Stream.t -> unitstream_to_file stream fileconverts aStream.tofjsonvalues to a newline separated list of compact json strings and outputs them tofile
val stream_to_buffer : Stdlib.Buffer.t -> json Stdlib.Stream.t -> unitstream_to_buffer buf streamconverts aStream.tofjsonvalues to compact strings and outputs them, separating by newlines, tobuf
Processing functions
module Process : sig ... endInternal modules
module Compliance : Jsonxt__.Compliance.S with type json = Json.Extended.json and type json_stream = Json_stream.Extended.json