package metadb

  1. Overview
  2. Docs

Module Metadb.JsonSource

This is a wrapper for the Yojson library

Sourcetype t = [
  1. | `Null
  2. | `Bool of bool
  3. | `Int of int
  4. | `Float of float
  5. | `String of string
  6. | `Assoc of (string * t) list
  7. | `List of t list
]

Type of Basic Json values

Sourceexception ParsingFailure of string
Sourceval get : string -> t -> t option

Get value of a key in a Json association list. Returns none if key is not found. Raises ParsingFailure if not an association list

Sourceval get_err : string -> t -> t

Same as get but raises ParsingFailure if key is unbound

Sourceval add_entry : string -> t -> t -> t

Add entry to an association list and raise ParsingFailure if not an association list

Sourceval remove_entry : string -> t -> t

Remove entry from association list and raise ParsingFailure if not an association list

Sourceval to_list : t -> t list

Convert a Json list to a list. Raise ParsingFailure if not a list

Sourceval to_int : t -> int

Convert a Json int to an int. Raise ParsingFailure if not an int

Sourceval to_string : t -> string

Convert Json string to a string. Raise ParsingFailure if not a string

Sourceval to_bool : t -> bool

Convert Json bool to bool. Raise ParsingFailure if not a bool

Sourceval raise_opt : string -> ([> `Null ] as 'a) option -> 'a

Convert t option to t and raise ParsingFailure with message specified by the first argument if None or `Null

Sourceval default : 'a -> ([> `Null ] as 'a) option -> 'a

Convert t option to t and return first argument if None or `Null

Sourceval write_string : t -> string

Write Json to string in a compact way

Sourceval pretty_to_string : t -> string

Write Json to string in a readable way

Sourceval from_string : string -> t

Parse Json from string

Sourceval to_file : Path.root -> t -> unit

Write Json to file

Sourceval from_file : Path.root -> t

Read Json from file

OCaml

Innovation. Community. Security.