Skip to main content

Decode

Returns the decoded value, or nil plus an error string if the text is not valid JSON.

Encode

Returns the JSON text, or nil plus an error string. Functions, userdata and threads cannot be encoded. Object keys must be strings or numbers. Number keys are converted to strings.

null

json.null preserves JSON null values inside Lua tables and encodes back to null.

Empty tables

{} and [] both decode to an empty Lua table, and an empty table encodes to []. Use json.EmptyObject when a server needs {}.

With HTTP

Nesting is capped at 200 levels deep, which also stops a table that contains itself from encoding forever.