![]() | Library Documentation | Structures | Signatures | Identifiers | Packages | About |
JSON (pkg github.com/diku-dk/sml-json)JSON library.
This library provides operations for parsing and constructing JSON values (represented by strings). JSON values are represented in SML by the type t, which may include key-value object maps that are represented by the type obj.structure Json : JSON (pkg github.com/diku-dk/sml-json)
signature JSON = sig
type obj (* object map *)
datatype t = RAW of string (* embedded JSON string *)
| OBJECT of obj
| STRING of string
| ARRAY of t list
| NULL
| BOOL of bool
| NUMBER of string
(* Operations on object maps *)
val objFromList : (string * t) list -> obj
val objFromKeyValues : (string * string) list -> obj
val objLook : obj -> string -> t option
val objFold : ((string * t) * 'a -> 'a) -> 'a -> obj -> 'a
val objList : obj -> (string * t) list
val objAdd : obj -> string -> t -> obj
val objEmp : obj
(* Operations on JSON values *)
val toString : t -> string
val fromKeyValues : (string * string) list -> t
val foldlArray : (t * 'a -> 'a) -> 'a -> t -> 'a
val foldrArray : (t * 'a -> 'a) -> 'a -> t -> 'a
val getBool : t -> string -> bool (* may raise Fail *)
val getString : t -> string -> string (* may raise Fail *)
val getStringOpt : t -> string -> string -> string
(* Operations directly on strings containing json *)
val fromString : string -> t
val foldlArrayJson : (t * 'a -> 'a) -> 'a -> string -> 'a
end