Module Jsonxt.Extended_stream
Extended_stream supports parsing and writing JSON data that conforms to the Json_stream.Extended.json type as a stream of Json_stream.Extended.json objects. This supports non-standard JSON types including integer as well as tuples and variants introduced by Yojson
type json_stream= Json_stream.Extended.json
Reader functions
include Jsonxt__.Reader_stream.Reader_stream with type json_stream := json_stream
json_stream_* and decode functions
val json_stream_of_string : string -> streamjson_stream_of_string screates a stream parser that returns a series ofjson_streamelements from the strings.
val json_stream_of_channel : Stdlib.in_channel -> streamjson_stream_of_channel iccreates a stream parser that returns a series ofjson_streamelements from thein_channelic.
val json_stream_of_function : (bytes -> int -> int) -> streamjson_stream_of_function fcreates a stream parser that returns a series ofjson_streamelements from the reader functionf.f buf lentakes a bufferbufand maximum lengthlenand returns the number of bytes read to a maximum oflen
val decode_stream : stream -> (json_stream option, string) Stdlib.resultdecode_stream tdecode the next element of the input,Ok Noneindicates 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.
val stream_from_string : string -> json_stream Stdlib.Stream.tstream_from_string screates ajson_stream Stream.tfromjson_stream_of_string sanddecode_stream
val stream_from_channel : Stdlib.in_channel -> json_stream Stdlib.Stream.tstream_from_channel iccreates ajson_stream Stream.tfromjson_stream_of_channel icanddecode_stream
val stream_from_function : (bytes -> int -> int) -> json_stream Stdlib.Stream.tstream_from_function fcreates ajson_stream Stream.tfromjson_stream_of_function fanddecode_stream
Writer functions
include Jsonxt__.Writer_stream_intf.Intf with type json_stream := json_stream
val create_encoder' : add_char:(char -> unit) -> add_string:(string -> unit) -> incr:int -> eol:string -> tcreate_encoder' ~add_char ~add_string ~incr ~eolis the low level function used to create the various stream encoders. Theadd_char candadd_string sfunctions handle adding acharcandstringsto the output respectively.incrandeolwork together to output human readable output.incrdefines the increase in indentation andeolthe end of line sequence. A typetis returned
val create_encoder : add_char:(char -> unit) -> add_string:(string -> unit) -> tcreate_encoder ~add_char ~add_stringcreates a compact encoder.add_charandadd_stringadd acharandstringto the output respectively A typetis returned
val create_encoder_hum : add_char:(char -> unit) -> add_string:(string -> unit) -> tcreate_encoder_hum ~add_char ~add_stringcreates a human readable encoder.add_charandadd_stringadd acharandstringto the output respectively. The increment is set to 2 and end of line to LF (\n). A typetis returned
val create_encoder_channel : Stdlib.out_channel -> tcreate_encoder_channel occreates a compact encoder outputing to channeloc
val create_encoder_channel_hum : Stdlib.out_channel -> tcreate_encoder_channel_hum occreates a human readable encoder outputing to channeloc
val encode_stream_exn : t -> json_stream -> unitencode_stream_exn t json_streamencodes and outputs the elementjson_stream. Errors cause a Failure exception to be raised.
val encode_stream : t -> json_stream -> (unit, string) Stdlib.resultencode_stream_exn t json_streamencodes and outputs the elementjson_stream. Errors are reported via theresultvalue.