Module Basic.Util
include Jsonxt__.Process_intf.Shared with type json := json
- val member : string -> [> `Assoc of (string * json) list ] -> json
- member key jsonsearches the JSON object- json, which must be an- `Assocelement, for- keyand returns the value or- `Nullif the- keyis missing
- val index : int -> [> `List of json list ] -> json
- index idx jsonreturns the- idx-th JSON object in the- jsonarray, which must be an- `Listelement. A negative- idxvalue starts from the end with -1 being the last element. A- Failureexception is raise if the idx is out of bounds
- val map : (json -> json) -> [> `List of json list ] -> [> `List of json list ]
- map f jsonapplies the function- fto each element of the JSON array- json, which must be an- `Listelement, and returns a- `Listelement
- val to_assoc : [> `Assoc of (string * json) list ] -> (string * json) list
- to_assoc jsonconverts the JSON object- `Assoc ato- a
- val to_bool_option : [> `Bool of bool | `Null ] -> bool option
- to_bool_option jsonconverts- `Bool bto- Some band- `Nullto- None
- val to_float_option : [> `Float of float | `Null ] -> float option
- to_float_option jsonconverts- `Float fto- Some fand- `Nullto- None
- val to_option : ([> `Null ] as 'a -> json) -> 'a -> json option
- to_option f jsonreturns- Noneif- jsonis- `Nullotherwise- Some (f json).
- val to_number_option : [> `Float of float | `Null ] -> float option
- to_number_option jsonconverts- `Float fto- Some fand- `Nullto- None
- val to_string_option : [> `String of string | `Null ] -> string option
- to_string_option jsonconverts- `String sto- Some sand- `Nullto- None
- val convert_each : (json -> json) -> [> `List of json list ] -> json list
- convert_each f jsonapplies the function- fto each element of the JSON array- json, which must be an- `Listelement, and returns a list of the returned values.
- val filter_map : ('a -> 'a option) -> 'a list -> 'a list
- filter_map f lapplies- fto each element of the list- land returns a new list with the values- vfor which- freturned- Some v.
- val rev_filter_map : ('a -> 'a option) -> 'a list -> 'a list -> 'a list
- rev_filter_map f acc lapplies- fto each element of the list- land prepends the values for which- freturned- Some vto list- acc.- accis returned as the result and is in reverse order to the input. This is a tail call optimised version of- filter_map
- val flatten : [> `List of 'a list ] list -> 'a list
- flatten lgiven a list of- jsonelements filters the- `Listelements and flattens them into a single list. This is the same as- filter_list |> List.flatten
- val rev_flatten : 'a list -> [> `List of 'a list ] list -> 'a list
- rev_flatten acc lis the tail recursive version of- flattenwith the result accumulated in- acc. The result is in reverse order.
- val filter_index : int -> [> `List of json list ] list -> json list
- filter_index i lreturns the- i'th element from each- `List l1in- l. Thus,- [[`List [`Int 2; `Int 3]; `List [`Int 4; `Int 5]] |> filter_index 1]- returns - [`Int 3; `Int 5]
- val filter_list : [> `List of 'a ] list -> 'a list
- filter_list lreturns a list of all the values of- `List valueelements in l
- val filter_assoc : [> `Assoc of 'a ] list -> 'a list
- filter_assoc lreturns a list of all the values of- `Assoc valueelements in l
- val filter_bool : [> `Bool of bool ] list -> bool list
- filter_bool lreturns a list of all the values of- `Bool valueelements in l
- val filter_float : [> `Float of float ] list -> float list
- filter_float lreturns a list of all the values of- `Float valueelements in l
- val filter_string : [> `String of string ] list -> string list
- filter_string lreturns a list of all the values of- `String valueelements in l
- val filter_member : string -> [> `Assoc of (string * json) list ] list -> json list
- filter_member key jsgiven a- keyand a list of json- `Assoc-s,- js, returns the list of values extracted from each of the- `Assoc-s. Thus,- [[`Assoc [("id", `Int 1)]; `Assoc [("id", `Int 2)]]] |> filter_member "id"]- returns - [`Int 1; `Int 2]
- val filter_number : [> `Float of float ] list -> float list
- filter_number lreturns a list of all the values of- `Float valueelements in l
- val keys : [> `Assoc of (string * 'a) list ] -> string list
- keys assocreturns all the keys from the- `Assocelement
- val values : [> `Assoc of (string * 'a) list ] -> 'a list
- values assocreturns all the values from the- `Assocelement
include Jsonxt__.Process_intf.Basic with type json := json
- val to_number : [> `Int of int | `Float of float ] -> float
- to_number jsonconverts- `Float fto- fand- Int ito- float i
- val to_number_option : [> `Int of int | `Float of float | `Null ] -> float option
- to_number_option jsonconverts- `Float fto- Some f,- `Int ito- Some (float i)and- `Nullto- None
- val to_int_option : [> `Int of int | `Null ] -> int option
- to_int_option jsonconverts- `Int ito- Some iand- `Nullto- None