Json

Parse and encode JSON on the host.

Methods
2
Fields
None

Getting one

Json

Methods

MethodReturnsDescription
parse(string)anyParse a JSON document into Luau values.
encode(any, { pretty: boolean? }?)stringSerialise a Luau value to JSON.

Method details

parse

parse: (string) -> any

Parse a JSON document into Luau values.

text
The document.
Returns
Errors on malformed input rather than returning nil.

encode

encode: (any, { pretty: boolean? }?) -> string

Serialise a Luau value to JSON.

value
The value to encode.
options
{ pretty = true } writes two spaces of indent, ": ", HTML-safe escaping, and leaves out an object member whose value is JsonNull.INSTANCE. Without it, compact JSON.