แยกวิเคราะห์ เข้ารหัส ตรวจสอบ และแปลง JSON
ฟังก์ชันที่ใช้ได้
json.array
สร้าง new table ที่ถูก mark เป็น JSON array สำหรับ json.encode และคัดลอก sequence 1.#source เมื่อมี source table
json.clone
clone value โดย encoding ด้วย json.encode semantics แล้ว decoding generated JSON กลับเป็น Lua values
json.decode
parse JSON string ด้วย Real JSON parser และคืน decoded Lua value พร้อม mark decoded arrays และ objects สำหรับ JSON helpers
json.decodeSafe
parse JSON ด้วย parser เดียวกับ json.decode และคืน success flag แทนการ throw สำหรับ parse errors
json.encode
serialize Lua value เป็น JSON string ด้วย Real JSON encoder. json.stringify ถูก register ไปยัง function เดียวกัน
json.encodePretty
Serializes Lua value เป็น readable formatted JSON string โดยใช้ Real JSON encoder. json.pretty ถูก register กับ function เดียวกัน.
json.escape
Escape string ด้วย Real JSON string escaping rules และคืน escaped content โดยไม่มี surrounding quotes.
json.format
Parse JSON string แล้ว re-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 แล้ว re-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
Serializes 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
serialize 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” table ส่งคืน “array” หรือ “object” โดยใช้ table classification เดียวกับ json.isArray และ json.isObject ค่าอื่นส่งคืน runtime Lua type name result
json.unescape
Decode JSON string escape sequences จาก escaped string content หรือจาก complete quoted JSON string literal อินพุตถูก parse ด้วย JSON string parser ไม่ใช่ full JSON document
json.validate
Validate JSON string โดย parse complete JSON value หนึ่งค่า เมื่อ success จะ return เฉพาะ true เมื่อ parse failure จะ return false พร้อม parser error details
json.values
คืน direct values จาก table ใน table ใหม่ที่ marked as JSON array. JSON type marker entries จะถูกข้าม