API / Core / Json / Encode

Encode

bool

RESCRIPT
let bool: bool => t

Returns a boolean as a JSON object.

Examples

RESCRIPT
JSON.Encode.bool(true)

null

RESCRIPT
let null: t

Returns null as a JSON object.

Examples

RESCRIPT
JSON.Encode.null

string

RESCRIPT
let string: string => t

Returns a string as a JSON object.

Examples

RESCRIPT
JSON.Encode.string("hello world")

int

RESCRIPT
let int: int => t

Returns an int as a JSON object.

Examples

RESCRIPT
JSON.Encode.int(42)

float

RESCRIPT
let float: float => t

Returns a float as a JSON object.

Examples

RESCRIPT
JSON.Encode.float(42.0)

object

RESCRIPT
let object: Core__Dict.t<t> => t

Returns a dict as a JSON object.

Examples

RESCRIPT
let dict = Dict.fromArray([ ("foo", JSON.Encode.string("bar")), ("hello", JSON.Encode.string("world")), ]) JSON.Encode.object(dict)

array

RESCRIPT
let array: array<t> => t

Returns an array as a JSON object.

Examples

RESCRIPT
let array = [JSON.Encode.string("hello world"), JSON.Encode.int(42)] JSON.Encode.array(array)