Skip to main content

الوسائط

string
مطلوب
JSON text للتفسير. يتم فحص هذا argument كـ string قبل catch لـ parse errors.
DecodeOptions
Optional decode options. قيمة boolean تضبط useNull مباشرة. table يمكن أن تضبط useNull و maxDepth؛ يتم clamp لـ maxDepth من 1 إلى 4096. Invalid option argument types يتم فحصها قبل catch لـ parse errors.

القيم الراجعة

boolean
True عندما ينجح parsing، و false عندما يبلغ parser عن error.
any | nil
Decoded value عند النجاح، و nil عند parse failure. JSON false صالح يعيد success كـ true و decoded كـ false، لذلك افحص success return value.
string | nil
Error message عند parse failure، وإلا nil. الرسالة تتضمن json.decodeSafe prefix و parser position.
number | nil
Parser byte position عند parse failure، وإلا nil.

الأنواع

DecodeOptions

يتحكم في سلوك تحليل JSON.

مثال

Parse JSON واستخدم success return value لتمييز valid false أو nil results عن parse failures.