JSON

json.parse

Alias-style JSON parser that behaves like json.decode.

Syntax

json.parse(json: string, options?: DecodeOptions): any

Arguments

NameTypeDescription
jsonstringJSON string to parse, format, minify, or validate.
options?DecodeOptionsOptional settings table that controls how the operation behaves.

Returns

NameTypeDescription
decodedanyDecoded Luau value or decoded byte string.

Description

Alias-style JSON parser that behaves like json.decode.

Call it with 2 parameter(s): json, options. The argument table explains which values are required and which ones only refine the behavior.

It returns decoded (any). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Parse JSON using the decode-compatible alias.

local settings = json.parse('{"volume":0.75,"theme":"dark"}')

print(settings.volume)
print(settings.theme)

Types

DecodeOptions

Controls JSON parsing behavior.

useNull? boolean Represents JSON null with the library's null sentinel instead of nil.maxDepth? integer Sets the maximum nesting depth, clamped from 1 to 4096.