Skip to main content
rb.json reads JSON text into Luau values and writes Luau values back out as JSON. A script reaches for it when settings or a reply arrive as JSON text, or when it has to hand a table on as text. This script reads a settings string, checks a null field, changes a value and writes the result back out:
stringify raises when the value holds a function, a thread, or a table with keys that are neither all strings nor a list. JSON null parses to a placeholder value, not nil. It is truthy and its key stays in the table, so if data.field then passes for a null field; test type(v) == "userdata" for null. stringify writes an empty table as {}; an array that came from parse keeps its brackets, even when empty. rb.file.read_json and write_json follow the same rules.