package geojson

  1. Overview
  2. Docs

Types for the JSON parser

type t

The type your parser uses to represent a parsed JSON object.

val find : t -> string list -> t option

Recursively find keys in nested objects.

val to_string : t -> (string, [ `Msg of string ]) Stdlib.result

Convert the JSON to a string.

val string : string -> t

Create a JSON string.

val to_float : t -> (float, [ `Msg of string ]) Stdlib.result

Convert the JSON to a float.

val float : float -> t

Converts a float to JSON

val to_int : t -> (int, [ `Msg of string ]) Stdlib.result

Convert the JSON to an integer.

val int : int -> t

Converts an integer to JSON

val to_list : (t -> 'a) -> t -> ('a list, [ `Msg of string ]) Stdlib.result

to_list f converts the JSON array to a list and applies f to each element to convert them too.

val list : ('a -> t) -> 'a list -> t

Make a JSON array from a list

val to_array : (t -> 'a) -> t -> ('a array, [ `Msg of string ]) Stdlib.result

Like to_list except to an array.

val array : ('a -> t) -> 'a array -> t

Like list except for OCaml arrays

val to_obj : t -> ((string * t) list, [ `Msg of string ]) Stdlib.result

Convert the JSON object to an association list

val obj : (string * t) list -> t

A JSON object from an association list

val null : t

Null value

val is_null : t -> bool

Test for null