package jsonxt
Module Basic_monad.MakeSource
The Make functor is used to create a module with reader and writer functions using the IO monad.
Parameters
Signature
The Make functor is used to create a module with reader and writer functions using the IO monad. This has the signature
module type IO = sig
type 'a t
val return : 'a -> 'a t
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t
endval read_json :
?stream:bool ->
reader:(Bytes.t -> int -> int IO.t) ->
unit ->
(Basic.Compliance.json, string) result IO.tread_json takes a reader function and returns a json value or an error if the string has syntax, grammar or compliance errors. The reader buf len parameter reads at most len bytes into buf and returns the number of bytes read. Zero indicates end of file. The optional stream parameter specifies if multiple json objects are to be read, defaulting to false
val json_writer :
writer:(string -> unit IO.t) ->
eol:string ->
incr:int ->
psep:string ->
Basic.Compliance.json ->
unit IO.tjson_writer ~writer ~eol ~incr ~psep json converts json to a string s and writes it out using the writer string function. incr, eol and psep work together to output human readable output. incr defines the increase in indentation, eol the end of line sequence and psep the string to seperate the : from the value in objects
The writer string function takes a string and returns a unit IO.t
create_encoder ~writer creates a compact encoder using json_writer.
create_encoder ~writer creates a human readable encoder using json_writer with incr set to 2 and eol to '\n'.