diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 26 |
1 files changed, 26 insertions, 0 deletions
| @@ -16,6 +16,7 @@ Table of Contents | |||
| 16 | * [encode_number_precision](#encode_number_precision) | 16 | * [encode_number_precision](#encode_number_precision) |
| 17 | * [encode_escape_forward_slash](#encode_escape_forward_slash) | 17 | * [encode_escape_forward_slash](#encode_escape_forward_slash) |
| 18 | * [encode_skip_unsupported_value_types](#encode_skip_unsupported_value_types) | 18 | * [encode_skip_unsupported_value_types](#encode_skip_unsupported_value_types) |
| 19 | * [encode_indent](#encode_indent) | ||
| 19 | * [decode_array_with_array_mt](#decode_array_with_array_mt) | 20 | * [decode_array_with_array_mt](#decode_array_with_array_mt) |
| 20 | 21 | ||
| 21 | Description | 22 | Description |
| @@ -201,6 +202,31 @@ This will generate: | |||
| 201 | 202 | ||
| 202 | [Back to TOC](#table-of-contents) | 203 | [Back to TOC](#table-of-contents) |
| 203 | 204 | ||
| 205 | encode_indent | ||
| 206 | ---------------------------- | ||
| 207 | **syntax:** `cjson.encode_indent(indent)` | ||
| 208 | |||
| 209 | If non-empty string provided, JSON values encoded by `cjson.encode()` will be | ||
| 210 | formatted in a human-readable way, using `indent` for indentation | ||
| 211 | at each nesting level. Also enables newlines and a space after colons. | ||
| 212 | |||
| 213 | Example: | ||
| 214 | |||
| 215 | ```lua | ||
| 216 | local cjson = require "cjson" | ||
| 217 | |||
| 218 | cjson.encode_indent(" ") | ||
| 219 | print(cjson.encode({ a = 1, b = { c = 2 } })) | ||
| 220 | -- { | ||
| 221 | -- "a": 1, | ||
| 222 | -- "b": { | ||
| 223 | -- "c": 2 | ||
| 224 | -- } | ||
| 225 | -- } | ||
| 226 | ``` | ||
| 227 | |||
| 228 | [Back to TOC](#table-of-contents) | ||
| 229 | |||
| 204 | decode_array_with_array_mt | 230 | decode_array_with_array_mt |
| 205 | -------------------------- | 231 | -------------------------- |
| 206 | **syntax:** `cjson.decode_array_with_array_mt(enabled)` | 232 | **syntax:** `cjson.decode_array_with_array_mt(enabled)` |
