package yocaml

  1. Overview
  2. Docs

Module Key_value.Jsonm_objectSource

Sourcetype t = [
  1. | `Null
  2. | `Bool of bool
  3. | `Float of float
  4. | `String of string
  5. | `A of t list
  6. | `O of (string * t) list
]
include VALIDABLE with type t := t

Types

Visitors

A visitor is quite simple and can be summarised as follows:

  let as_xxxx valid invalid observed_value =
    if is_xxx observed_value
    then valid (extract_xxx observed_value)
    else invalid ()
  ;;
Sourceval as_object : (t, (string * t) list, 'a) visitor

Visitor for Objects. For example, in Ezjsonm (which is a simpler wrapper for the Jsonm library), The AST is described in this way:

  type value =
    [ `Null
    | `Bool of bool
    | `Float of float
    | `String of string
    | `A of value list
    | `O of (string * value) list
    ]

Implementing as_object would be like writing this:

  let as_object valid invalid = function
    | `O kv -> valid kv
    | _ -> invalid ()
  ;;
Sourceval as_list : (t, t list, 'a) visitor

Visitor for List.

Sourceval as_atom : (t, string, 'a) visitor

Visitor for Atoms.

Sourceval as_string : (t, string, 'a) visitor

Visitor for String.

Sourceval as_boolean : (t, bool, 'a) visitor

Visitor for Boolean.

Sourceval as_integer : (t, int, 'a) visitor

Visitor for Integer.

Sourceval as_float : (t, float, 'a) visitor

Visitor for Float.

Sourceval as_null : (t, unit, 'a) visitor

Visitor for Null.

OCaml

Innovation. Community. Security.