Module Js.JsonSource

JSON encoding/decoding with JSON.parse / JSON.stringify semantics

Sourcetype t
Sourcetype _ kind =
  1. | String : string kind
  2. | Number : float kind
  3. | Object : t Js__.Js_dict.t kind
  4. | Array : t array kind
  5. | Boolean : bool kind
  6. | Null : Js__.Js_types.null_val kind
Sourcetype tagged_t =
  1. | JSONFalse
  2. | JSONTrue
  3. | JSONNull
  4. | JSONString of string
  5. | JSONNumber of float
  6. | JSONObject of t Js__.Js_dict.t
  7. | JSONArray of t array
Sourceval classify : t -> tagged_t
Sourceval test : t -> 'b kind -> bool

Note: Melange's test accepts any 'a; natively the first argument is narrowed to t because values carry no runtime type information.

Sourceval decodeString : t -> string option
Sourceval decodeNumber : t -> float option
Sourceval decodeObject : t -> t Js__.Js_dict.t option
Sourceval decodeArray : t -> t array option
Sourceval decodeBoolean : t -> bool option
Sourceval decodeNull : t -> 'a option option
Sourceval parseExn : string -> t
  • raises Js_exn.SyntaxError

    if the string is not valid JSON.

Sourceval stringifyAny : 'a -> string option
  • alert not_implemented is not implemented in native under server-reason-react.js
Sourceval null : t
Sourceval string : string -> t
Sourceval number : float -> t
Sourceval boolean : bool -> t
Sourceval object_ : t Js__.Js_dict.t -> t
Sourceval array : t array -> t
Sourceval stringArray : string array -> t
Sourceval numberArray : float array -> t
Sourceval booleanArray : bool array -> t
Sourceval objectArray : t Js__.Js_dict.t array -> t
Sourceval stringify : t -> string
Sourceval stringifyWithSpace : t -> int -> string
Sourceval patch : t -> t
Sourceval serializeExn : t -> string
  • alert not_implemented is not implemented in native under server-reason-react.js
Sourceval deserializeUnsafe : string -> 'a
  • alert not_implemented is not implemented in native under server-reason-react.js