json Reference
Module defined in `lua/common/json.lua`. High-performance SJSON (Simplified JSON) parser for Lua 5.1/LuaJIT. Supports standard JSON plus SJSON extensions: comments (`//`, `/* */`), unquoted keys, `=`
Module defined in lua/common/json.lua. High-performance SJSON (Simplified JSON) parser for Lua 5.1/LuaJIT. Supports standard JSON plus SJSON extensions: comments (//, /* */), unquoted keys, = as key-value separator, and trailing commas.
Exports
Functions
M.decode(si)
Parses a JSON/SJSON string into a Lua table.
- Parameters:
si- string|nil - JSON string to parse
- Returns:
self(module table, for chaining)
Internal Notes
- Dispatch-table driven parser - each byte value maps to a parsing function for maximum speed
- Handles: objects
{}, arrays[], strings"", numbers (including1#INF00, scientific notation), booleans, null,Infinity - SJSON extensions:
//single-line comments,/* */block comments, unquoted alphanumeric keys,=as separator (in addition to:) - Temporarily stops the garbage collector during parsing for performance
- Handles escape sequences:
\t,\n,\f,\r,\b,\",\\ - Error messages include approximate line numbers
- Uses
table.newandtable.clearLuaJIT extensions with fallbacks - This is the fast/production parser; see
jsonDebug.luafor the version with duplicate key warnings
json-ast Reference
Module defined in `lua/common/json-ast.lua`. A JSON/jbeam AST (Abstract Syntax Tree) parser that preserves formatting, comments, and whitespace. Used by the in-game jbeam editor for lossless round-tri
jsonDebug Reference
Module defined in `lua/common/jsonDebug.lua`. Debug variant of the SJSON parser that adds duplicate key detection. Structurally identical to `json.lua` but emits warnings when duplicate keys are found