Skip to main content

Đối số

string
bắt buộc
JSON text de parse. argument nay duoc kiem tra la string truoc khi parse errors duoc catch.
DecodeOptions
Optional decode options. boolean dat useNull truc tiep. table co the dat useNull va maxDepth; maxDepth duoc clamp tu 1 den 4096. Invalid option argument types duoc kiem tra truoc khi parse errors duoc catch.

Giá trị trả về

boolean
True khi parsing thanh cong, false khi parser bao error.
any | nil
Decoded value khi thanh cong, nil khi parse failure. JSON false hop le tra ve success la true va decoded la false, vi vay hay kiem tra success return value.
string | nil
Error message khi parse failure, nguoc lai nil. message bao gom json.decodeSafe prefix va parser position.
number | nil
Parser byte position khi parse failure, nguoc lai nil.

Kiểu

DecodeOptions

Kiểm soát hành vi phân tích cú pháp JSON.

Ví dụ

Parse JSON va dung success return value de tach valid false hoac nil results khoi parse failures.