Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/util.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
exception Type_error of string * t
exception Missing_Member of string

let typeof = function
| `Assoc _ -> "object"
Expand Down Expand Up @@ -26,6 +27,12 @@ let member name = function
| `Assoc obj -> assoc name obj
| js -> typerr ("Can't get member '" ^ name ^ "' of non-object type ") js

let assoc_force name obj = try List.assoc name obj with Not_found -> raise (Missing_Member ("There is no member called " ^ name ^ "in the json object"))

let member_force name = function
| `Assoc obj -> assoc_force name obj
| js -> typerr ("Can't get member '" ^ name ^ "' of non-object type ") js

let rec path l obj =
match l with
| [] -> Some obj
Expand Down