Category

JSON

Parse, encode, inspect, and transform JSON.

Category guide

Overview

Use this overview to understand the category before opening a specific function.
  • See what this group of functions is meant to solve.
  • Compare function names and descriptions in one table.
  • Open a function for syntax, arguments, returns, and examples.

JSON

Available functions

24 functions
FunctionDescription
json.arrayCreates a new table marked as a JSON array for json.encode, copying the 1.#source sequence when a source table is provided.
json.cloneClones a value by encoding it with json.encode semantics and decoding the generated JSON back into Lua values.
json.decodeParses a JSON string with Real's JSON parser and returns the decoded Lua value, marking decoded arrays and objects for the JSON helpers.
json.decodeSafeParses JSON with the same parsing behavior as json.decode and returns a success flag instead of throwing for parse errors.
json.encodeSerializes a Lua value to a JSON string as JSON.
json.encodePrettySerializes a Lua value to a readable formatted JSON string as JSON.
json.escapeEscapes a string using Real's JSON string escaping rules and returns the escaped content without surrounding quotes.
json.formatParses a JSON string and re-encodes it as readable formatted JSON using Real's JSON parser and encoder.
json.getPathReads a nested value from a table using a dotted string path or an array table of keys.
json.isArrayReturns whether a value is treated as a JSON array by Real's JSON table detection.
json.isNullReturns whether a value is Real's JSON null sentinel, json.null.
json.isObjectReturns whether a value is treated as a JSON object by Real's JSON table detection.
json.keysReturns the visible keys of a table in a new table marked as a JSON array.
json.minifyParses a JSON string and re-encodes it with Real's default non-pretty JSON encoder output.
json.objectCreates a new table marked as a JSON object so Real's JSON encoder treats it as an object.
json.parseParses a JSON string like json.decode.
json.prettySerializes a Lua value to a readable formatted JSON string like json.encodePretty.
json.quoteEscapes a string using Real's JSON string escaping rules and returns a complete quoted JSON string literal.
json.stringifySerializes a Lua value to a JSON string like json.encode.
json.tryDecodeAttempts to parse a JSON string like json.decodeSafe and returns status values for parse errors.
json.typeReturns a string type name for a value.
json.unescapeDecodes JSON string escape sequences from escaped string content or from a complete quoted JSON string literal.
json.validateValidates a JSON string by parsing one complete JSON value.
json.valuesReturns the direct values from a table in a new JSON array table.