تحليل وترميز وفحص وتحويل JSON.
الدوال المتاحة
json.array
ينشئ new table مميزة كـ JSON array من أجل json.encode، وينسخ sequence من 1.#source عند توفير source table.
json.clone
ينسخ value عبر encoding باستخدام json.encode semantics ثم decoding للـ generated JSON مرة أخرى إلى Lua values.
json.decode
يفسر JSON string باستخدام Real JSON parser ويعيد decoded Lua value، مع تعليم decoded arrays و objects من أجل JSON helpers.
json.decodeSafe
يفسر JSON باستخدام نفس parser مثل json.decode ويعيد success flag بدلا من الرمي عند parse errors.
json.encode
يعمل serialize لـ Lua value إلى JSON string باستخدام Real JSON encoder. json.stringify مسجل لنفس function.
json.encodePretty
يسلسل Lua value إلى JSON string منسق وقابل للقراءة باستخدام Real JSON encoder. json.pretty مسجل على نفس function.
json.escape
يعمل escape على string باستخدام Real JSON string escaping rules ويرجع escaped content بدون surrounding quotes.
json.format
يعمل parse لـ JSON string ثم يعيد encode له كـ readable formatted JSON باستخدام Real JSON parser و encoder.
json.getPath
يقرأ nested value من table باستخدام dotted string path او array table of keys.
json.isArray
يرجع ما اذا كان value يتم treated as a JSON array بواسطة Real JSON table detection.
json.isNull
يرجع ما اذا كان value هو Real JSON null sentinel، json.null.
json.isObject
يرجع ما اذا كان value يتم treated as a JSON object بواسطة Real JSON table detection.
json.keys
يرجع visible keys من table في new table marked as a JSON array.
json.minify
يعمل parse لـ JSON string ثم يعيد encode له باستخدام Real default non-pretty JSON encoder output.
json.object
ينشئ new table marked as a JSON object حتى يعاملها Real JSON encoder كـ object.
json.parse
يعمل parse لـ JSON string باستخدام نفس function مثل json.decode.
json.pretty
يسلسل Lua value إلى readable formatted JSON string باستخدام نفس function مثل json.encodePretty.
json.quote
يعمل escape لـ string باستخدام Real JSON string escaping rules ويرجع complete quoted JSON string literal.
json.stringify
يسلسل Lua value إلى JSON string باستخدام نفس function مثل json.encode.
json.tryDecode
يحاول parse لـ JSON string باستخدام نفس function مثل json.decodeSafe ويرجع status values لـ parse errors.
json.type
ترجع string type name لقيمة. json.null يرجع “null”. الجداول ترجع “array” أو “object” باستخدام نفس table classification مثل json.isArray و json.isObject. القيم الأخرى ترجع runtime Lua type name result.
json.unescape
يفك JSON string escape sequences من escaped string content أو من complete quoted JSON string literal. يتم parse للمدخل باستخدام JSON string parser، وليس كـ full JSON document.
json.validate
يتحقق من JSON string عن طريق parse لقيمة JSON واحدة complete. عند success يرجع true فقط. عند parse failure يرجع false مع parser error details.
json.values
يرجع direct values من table في table جديدة marked as JSON array. يتم تخطي JSON type marker entries.