aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorskewb1k <skewb1kunix@gmail.com>2026-01-19 08:51:57 +0800
committerGitHub <noreply@github.com>2026-01-19 08:51:57 +0800
commitea05d06f5a56d94d423fc697561a33ca3b8bf085 (patch)
tree48fbfc307052ed233b9ccf0b39ee569b3467d244 /README.md
parent3c64e2247623a66347a48d66b6a791b58a71fdbe (diff)
downloadlua-cjson-ea05d06f5a56d94d423fc697561a33ca3b8bf085.tar.gz
lua-cjson-ea05d06f5a56d94d423fc697561a33ca3b8bf085.tar.bz2
lua-cjson-ea05d06f5a56d94d423fc697561a33ca3b8bf085.zip
feature: add option to indent encoded output.HEADmaster
Diffstat (limited to 'README.md')
-rw-r--r--README.md26
1 files changed, 26 insertions, 0 deletions
diff --git a/README.md b/README.md
index debe1ae..d2094b1 100644
--- a/README.md
+++ b/README.md
@@ -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
21Description 22Description
@@ -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
205encode_indent
206----------------------------
207**syntax:** `cjson.encode_indent(indent)`
208
209If non-empty string provided, JSON values encoded by `cjson.encode()` will be
210formatted in a human-readable way, using `indent` for indentation
211at each nesting level. Also enables newlines and a space after colons.
212
213Example:
214
215```lua
216local cjson = require "cjson"
217
218cjson.encode_indent(" ")
219print(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
204decode_array_with_array_mt 230decode_array_with_array_mt
205-------------------------- 231--------------------------
206**syntax:** `cjson.decode_array_with_array_mt(enabled)` 232**syntax:** `cjson.decode_array_with_array_mt(enabled)`