package jsonxt
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=71eb44d6e6deefa4b3ba7595d22f8e684ffb686c6a306679489c4e09779ee96b
sha512=4ca7c252d8cd3d3eb39f8094d16c7e1b14968ab61b314c1937248209785bedf434c2b422eb5961d896a41cd70565f9675f11f26b2ccc4e1e34c30260eed5d97b
doc/jsonxt/Jsonxt/Basic_stream/index.html
Module Jsonxt.Basic_streamSource
Basic_stream supports parsing and writing JSON data that conforms to the Json_stream.Basic.json type as a stream of Json_stream.Basic.json objects. This includes support for integers which are not part of the JSON standard
Reader functions
The steaming reader provides two interfaces to decode input into a stream of json_stream elements
- The internal create_* and decode_stream mechanism
- A stream_from_*
json_stream Stream.tbased approach
Note that the returned stream has no structure thus [1,2,3] will be returned as the stream `Ae, `Int 1, `Int 2, `Int 3, `Ae (assuming basic or extended compliance)
json_stream_* and decode functions
json_stream_of_string s creates a stream parser that returns a series of json_stream elements from the string s.
json_stream_of_channel ic creates a stream parser that returns a series of json_stream elements from the in_channel ic.
json_stream_of_function f creates a stream parser that returns a series of json_stream elements from the reader function f. f buf len takes a buffer buf and maximum length len and returns the number of bytes read to a maximum of len
decode_stream t decode the next element of the input, Ok None indicates end of the stream
Stream.t functions
These functions provide a Stream.t API on top of the json_stream_of_* and decode_stream functions.
stream_from_string s creates a json_stream Stream.t from json_stream_of_string s and decode_stream
stream_from_channel ic creates a json_stream Stream.t from json_stream_of_channel ic and decode_stream
stream_from_function f creates a json_stream Stream.t from json_stream_of_function f and decode_stream
Writer functions
val create_encoder' :
add_char:(char -> unit) ->
add_string:(string -> unit) ->
incr:int ->
eol:string ->
tcreate_encoder' ~add_char ~add_string ~incr ~eol is the low level function used to create the various stream encoders. The add_char c and add_string s functions handle adding a char c and string s to the output respectively.
incr and eol work together to output human readable output. incr defines the increase in indentation and eol the end of line sequence. A type t is returned
create_encoder ~add_char ~add_string creates a compact encoder. add_char and add_string add a char and string to the output respectively A type t is returned
create_encoder_hum ~add_char ~add_string creates a human readable encoder. add_char and add_string add a char and string to the output respectively. The increment is set to 2 and end of line to LF (\n). A type t is returned
create_encoder_channel oc creates a compact encoder outputing to channel oc
create_encoder_channel_hum oc creates a human readable encoder outputing to channel oc
encode_stream_exn t json_stream encodes and outputs the element json_stream. Errors cause a Failure exception to be raised.
encode_stream_exn t json_stream encodes and outputs the element json_stream. Errors are reported via the result value.