Skip to content

json

luau
local json = require("@std/json")

json.asArray

Returns value as an Array if it is a JSON array, or nil otherwise.

luau
(value: Value) -> Array?

json.asObject

Returns value as an Object if it is a JSON object, or nil otherwise.

luau
(value: Value) -> Object?

json.deserialize

Parses a JSON string and returns the corresponding Luau value. Returns json.null for a JSON null literal; compare with json.null rather than nil to check for null.

luau
(src: string) -> (Array | Object | boolean | number | string)?

json.object

Creates a JSON Object from props. Use this to distinguish an empty object {} from an empty array when serializing.

luau
(props: { [string]: Value }) -> Object

json.serialize

Serializes value to a JSON string. If prettyPrint is true, the output is indented for readability.

luau
(value: Value, prettyPrint: boolean?) -> string