Skip to main content
reskate.json turns Lua values into JSON text and JSON text into Lua values. It needs no permission. Storage and the calls and events between plugins (libraries) copy values by the same rules.

How values map

A table that mixes the two (string keys and list keys, or list keys with gaps) cannot be turned into JSON. Functions, vectors, buffers, threads and userdata cannot either, nor NaN or infinity.

reskate.json.encode(value, pretty)

JSON text for a value.
any
required
A value as the table above allows. Tables nest at most 32 deep.
boolean
default:"false"
true for text indented by two spaces; otherwise it is on one line.
string
The JSON text.
Raises an error for a value that cannot be turned into JSON, tables nested deeper than 32, or a value larger than 1,048,576 values or 16 MB of text.

reskate.json.decode(text)

The Lua value JSON text holds. Objects become tables with string keys, arrays become lists, numbers become numbers, and null becomes nil (so an object’s null member is simply missing).
string
required
JSON text, at most 16 MB. A leading UTF-8 byte order mark is skipped.
any
The value.
Raises an error for text that is not valid JSON (the message gives the byte where it went wrong), text after the value, a key used twice in one object, nesting deeper than 64, more than 16 MB or 1,048,576 values, or invalid UTF-8. Wrap it in pcall when the text comes from outside your plugin.