package b0

  1. Overview
  2. Docs

JSON value queries.

Queries

type 'a t

The type for a query on a JSON value returning values of type 'a.

val null : unit t

null queries a null JSON value.

val nullable : 'a t -> 'a option t

nullable q queries either a null JSON value or with q.

val bool : bool t

bool queries a boolean JSON value.

val int : int t

int queries a float JSON value and truncates it.

val float : float t

float queries a float JSON value.

val string : string t

string queries a string JSON value.

val array : 'a t -> 'a list t

array q queries the elements of a JSON array with q.

val mem : string -> 'a t -> ('a -> 'b) t -> 'b t

mem name q o queries a JSON object o's member named name with q.

val mem_opt : string -> 'a t -> ('a option -> 'b) t -> 'b t

mem_opt name q queries a JSON object o's optional member named name with q.

val obj : 'a -> 'a t

obj v queries an object and returns v.

val json : Json.t t

json queries any JSON value.

val get : 'a -> 'a

get is the identity function

val sel : string -> 'a t -> 'a t

sel name q is obj get |> mem name q

val query : 'a t -> Json.t -> ('a, string) result

query q j queries a JSON value j with q.

OCaml

Innovation. Community. Security.