Module OLinq_json

module OLinq_json: sig .. end

Interface to Yojson

The type OLinq_json.json is basically Yojson.Safe.json

STATUS: EXPERIMENTAL


type ('a, [< `Any | `AtMostOne | `One ]) query = ('a, [< `Any | `AtMostOne | `One ] as 'b) OLinq.t 
type json = [ `Assoc of (string * json) list
| `Bool of bool
| `Float of float
| `Int of int
| `Intlit of string
| `List of json list
| `Null
| `String of string
| `Tuple of json list
| `Variant of string * json option ]
val as_list : (json, [< `Any | `AtMostOne | `One ]) query ->
(json list, [ `Any ]) query
val as_assoc : (json, [< `Any | `AtMostOne | `One ]) query ->
((string * json) list, [ `Any ]) query
val as_bool : (json, [< `Any | `AtMostOne | `One ]) query ->
(bool, [ `Any ]) query
val as_int : (json, [< `Any | `AtMostOne | `One ]) query ->
(int, [ `Any ]) query
val as_int_lit : (json, [< `Any | `AtMostOne | `One ]) query ->
(string, [ `Any ]) query
val as_float : (json, [< `Any | `AtMostOne | `One ]) query ->
(float, [ `Any ]) query
val as_null : (json, [< `Any | `AtMostOne | `One ]) query ->
(unit, [ `Any ]) query
val as_string : (json, [< `Any | `AtMostOne | `One ]) query ->
(string, [ `Any ]) query
val as_tuple : (json, [< `Any | `AtMostOne | `One ]) query ->
(json list, [ `Any ]) query
val as_variant : (json, [< `Any | `AtMostOne | `One ]) query ->
(string * json option, [ `Any ]) query
val assoc : string ->
(json, [< `Any | `AtMostOne | `One ]) query ->
(json, [ `Any ]) query
Assuming the json is an object, obtain the given key, otherwise empty
val enter_assoc : (json, [< `AtMostOne | `One ]) query ->
(string * json, [ `Any ]) query
val enter_list : (json, [< `Any | `AtMostOne | `One > `AtMostOne `One ])
query -> (json, [ `Any ]) query
If the json is a list, enter each of its element
val enter_tuple : (json, [< `AtMostOne | `One ]) query ->
(json, [ `Any ]) query
val enter_tuple_index : (json, [< `Any | `AtMostOne | `One ]) query ->
(int * json, [ `Any ]) query
val map_list : (json -> (json, [ `One ]) query) ->
json -> (json, [ `AtMostOne | `One ]) query
map_list f j maps f over each element of j, if j is a list, and replaces each element with the resulting json value, and wraps those again into a json list
val map_assoc : (string -> json -> (json, [ `One ]) query) ->
json -> (json, [ `AtMostOne | `One ]) query
map_assoc f j maps each value of j, assuming j is an `Assoc, and wraps again in an assoc.