jsonxt

Jsonxt - JSON parsers for files, strings and more
IN THIS PACKAGE
Module Jsonxt . Basic_monad . Make

Parameters

module IO : IO

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
end
val read_json : ?stream:bool -> reader:( Bytes.t -> int -> int IO.t ) -> unit -> ( Basic.Compliance.json, string ) result IO.t

read_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.t

json_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

val write_json : writer:( string -> unit IO.t ) -> Basic.Compliance.json -> unit IO.t

create_encoder ~writer creates a compact encoder using json_writer.

val write_json_hum : writer:( string -> unit IO.t ) -> Basic.Compliance.json -> unit IO.t

create_encoder ~writer creates a human readable encoder using json_writer with incr set to 2 and eol to '\n'.