JSON

json.parse

json.decode のように動作するエイリアス スタイルの JSON パーサー。

構文

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

引数

名前説明
jsonstring解析、フォーマット、縮小、または検証する JSON 文字列。
options?DecodeOptions操作の動作を制御するオプションの設定テーブル。

戻り値

名前説明
decodedanyデコードされた Luau 値またはデコードされたバイト文字列。

説明

json.decode のように動作するエイリアス スタイルの JSON パーサー。

2 個のパラメータで呼び出します: json, options。引数表では必須値と動作を調整する値を確認できます。

decoded (any) を返します。戻り値表を使って成功値、nil 結果、回復可能なエラーを分けて扱ってください。

デコード互換のエイリアスを使用して JSON を解析します。

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

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

DecodeOptions

JSON 解析動作を制御します。

useNull? boolean nil の代わりにライブラリの null センチネルを使用して JSON null を表します。maxDepth? integer ネストの最大の深さを 1 ~ 4096 の範囲で設定します。