Syntax
json.minify(json: string, options?: DecodeOptions): stringArguments
| Name | Type | Description |
|---|---|---|
json | string | JSON string to parse before minifying. The function reads this argument with string type checking. |
options? | DecodeOptions | Optional decode options used while parsing the input JSON. A boolean sets useNull. A table can set useNull and maxDepth. |
Returns
| Name | Type | Description |
|---|---|---|
minified | string | JSON string produced after parsing and re-encoding the input with default encode options. |
Description
Parses a JSON string and re-encodes it with Real's default non-pretty JSON encoder output.
Call it with 2 parameter(s): json, options. The argument table explains which values are required and which ones only refine the behavior.
It returns minified (string). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Parse valid JSON and re-encode it with default compact JSON output.
local formatted = [[{
"name": "Real",
"enabled": true,
"missing": null
}]]
print(json.minify(formatted, {
useNull = true,
}))Types
DecodeOptions
Controls JSON parsing behavior.
useNull? boolean Represents JSON null with the library's null sentinel instead of nil.maxDepth? integer Sets the maximum nesting depth, clamped from 1 to 4096.