Json.Encode
Provides functions for encoding a JSON data structure
null
is the singleton null JSON value
val nullable : 'a encoder -> 'a option -> Js.Json.t
nullable encoder option
returns either the encoded value or null
val withDefault : Js.Json.t -> 'a encoder -> 'a option -> Js.Json.t
withDefault default encoder option
returns the encoded value if present, oterwise default
pair encoder encoder tuple
creates a JSON array from a tuple of size 2
tuple2 encoder encoder tuple
creates a JSON array from a tuple of size 2. Alias of pair
tuple3 enc enc enc tuple
creates a JSON array from a tuple of size 3
val tuple4 :
'a encoder ->
'b encoder ->
'c encoder ->
'd encoder ->
('a * 'b * 'c * 'd) ->
Js.Json.t
tuple4 enc enc enc enc tuple
creates a JSON array from a tuple of size 4
dict encoder d
makes a JSON object of the Js.Dict.t
d
with the given encoder
object_ props
makes a JSON object of the props
list of properties
array encoder l
makes a JSON array of the list
l
using the given encoder
* NOTE: This will be renamed `array` once the existing and deprecated `array` function * has been removed.
list encoder a
makes a JSON array of the array
a
using the given encoder
The functions below are specialized for specific array type which happened to be already JSON object in the BuckleScript runtime. Therefore they are more efficient (constant time rather than linear conversion).