Module Reader_string_file.Make
Parameters
Signature
- type json- = Parser.Compliance.json
- val json_of_string : string -> (json, string) Stdlib.result
- json_of_string stringconverts- stringto a- jsonvalue returing an error if the string has syntax, grammar or compliance errors
- val json_of_string_exn : string -> json
- json_of_string_exn stringconverts- stringto a- jsonvalue raising a- Failureexception if the string has syntax, grammar or compliance errors
- val json_of_file : string -> (json, string) Stdlib.result
- json_of_file fileconverts the text from- fileto a- jsonvalue 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 -> json
- json_of_file fileconverts the text from- fileto a- jsonvalue raising a- Failureexception 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.result
- json_of_channel channelconverts the text from- channelto a- jsonvalue 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 -> json
- json_of_channel channelconverts the text from- channelto a- jsonvalue raising a- Failureexception 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.result
- json_of_function fconverts text provided by- fto a- jsonvalue returing an error if the supplied text has syntax, grammar or compliance errors. The function- f buf lentakes a- bytes- bufbuffer, the maximum number of bytes to read- lenand returns the number of bytes read. Returning 0 indicates end-of-file
- val json_of_function_exn : (bytes -> int -> int) -> json
- json_of_function_exn fconverts text provided by- fto a- jsonvalue raising a- Failureexception if the channel contents have syntax, grammar or compliance errors. See- json_of_functionfor detail of function- f
- val json_of_lexbuf : Stdlib.Lexing.lexbuf -> (json, string) Stdlib.result
- json_of_lexbuf lexbufconverts text in the supplied- lexbufto a- jsonvalue 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 -> json
- json_of_lexbuf_exn lexbufconverts text in the supplied- lexbufto a- jsonvalue raising a- Failureexception 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 -> json
- of_stringis an alias for json_of_string_exn
- val of_file : string -> json
- of_fileis an alias for json_of_file_exn
- val of_channel : Stdlib.in_channel -> json
- of_channelis an alias for json_of_channel_exn
- val of_function : (bytes -> int -> int) -> json
- of_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, Jsonxt.Error_info.t) Stdlib.result
- val json_of_file_error_info : string -> (json, Jsonxt.Error_info.t) Stdlib.result
- val json_of_channel_error_info : Stdlib.in_channel -> (json, Jsonxt.Error_info.t) Stdlib.result
- val json_of_function_error_info : (bytes -> int -> int) -> (json, Jsonxt.Error_info.t) Stdlib.result
- val json_of_lexbuf_error_info : Stdlib.Lexing.lexbuf -> (json, Jsonxt.Error_info.t) Stdlib.result
compatablity functions for internal use
- val json_of_lexbuf_error_info_compat : ?stream:bool -> Stdlib.Lexing.lexbuf -> (json option, Jsonxt.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.t
- stream_from_string stringconverts- stringcontaining zero or more json object to a- json Stream.tvalue raising a- Failureexception if the string has syntax, grammar or compliance errors
- val stream_from_channel : ?fin:(unit -> unit) -> Stdlib.in_channel -> json Stdlib.Stream.t
- stream_from_channel in_channelconverts the text from- in_channel, containing zero or more json objects, to a- json Stream.tvalue raising a- Failureexception if the file has syntax, grammar or compliance errors. The optional parameter- finspecifies a function to call when all json objects have been returned or a failure occurs
- val stream_from_file : string -> json Stdlib.Stream.t
- stream_from_file filenameconverts the text from file- filename, containing zero or more json objects, to a- json Stream.tvalue raising a- Failureexception if the file has syntax, grammar or compliance errors
- val stream_from_function : (bytes -> int -> int) -> json Stdlib.Stream.t
- stream_from_function fconverts text provided by- f, containing zero of more JSON objects, to a- json Stream.tvalue raising a- Failureexception if the file has syntax, grammar or compliance errors. The function- f buf lentakes a- bufbuffer to fill, the maximum number of bytes to read- lenand returns the number of bytes read. Returning 0 indicates end-of-file
- val stream_from_lexbuf : Stdlib.Lexing.lexbuf -> json Stdlib.Stream.t
- stream_from_file lexbufconverts the text from- lexbuf, containing zero or more json objects, to a- json Stream.tvalue raising a- Failureexception 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.t
- val stream_from_channel_error_info : ?fin:(unit -> unit) -> Stdlib.in_channel -> json Stdlib.Stream.t
- val stream_from_file_error_info : string -> json Stdlib.Stream.t
- val stream_from_function_error_info : (bytes -> int -> int) -> json Stdlib.Stream.t
- val stream_from_lexbuf_error_info : Stdlib.Lexing.lexbuf -> json Stdlib.Stream.t