Skip to main content

Arguments

any
required
Value to encode and decode. Supported JSON values round-trip with JSON; unsupported types encode as null unless encode options request an error.
EncodeOptions
Optional encode options passed to the encode step, such as sortKeys, emptyTableAsArray, errorOnUnsupported, encodeInvalidNumbersAsNull, maxDepth, pretty, and indent.

Returns

any
Decoded value produced from the encoded JSON. Objects and arrays are new tables with JSON kind markers from the decoder; JSON null values decode to json.null.

Types

EncodeOptions

Controls JSON serialization and formatting.

Example

Round-trip a JSON-compatible value through json.encode and json.decode before changing nested values.