aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlijunlong <lijunlong@openresty.com>2024-08-01 09:23:08 +0800
committerlijunlong <lijunlong@openresty.com>2024-08-01 09:23:44 +0800
commit91ca29db9a4a4fd0eedaebcd5d5f3ba2ace5ae63 (patch)
treecb3dacd8df87900d92eb154546b7691f31f3110e
parentb0b4c58df8fba8f7ea36c69bbdb517f9732b1bcf (diff)
downloadlua-cjson-91ca29db9a4a4fd0eedaebcd5d5f3ba2ace5ae63.tar.gz
lua-cjson-91ca29db9a4a4fd0eedaebcd5d5f3ba2ace5ae63.tar.bz2
lua-cjson-91ca29db9a4a4fd0eedaebcd5d5f3ba2ace5ae63.zip
doc: added doc for encode_skip_unsupported_value_types.HEAD2.1.0.14master
-rw-r--r--README.md30
1 files changed, 30 insertions, 0 deletions
diff --git a/README.md b/README.md
index 1ab0d5a..debe1ae 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,7 @@ Table of Contents
15 * [empty_array_mt](#empty_array_mt) 15 * [empty_array_mt](#empty_array_mt)
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 * [decode_array_with_array_mt](#decode_array_with_array_mt) 19 * [decode_array_with_array_mt](#decode_array_with_array_mt)
19 20
20Description 21Description
@@ -171,6 +172,35 @@ If disabled, forward slash '/' will be encoded as '/' (no escape is applied).
171 172
172[Back to TOC](#table-of-contents) 173[Back to TOC](#table-of-contents)
173 174
175encode_skip_unsupported_value_types
176---------------------------
177**syntax:** `cjson.encode_skip_unsupported_value_types(enabled)`
178
179**default:** false
180
181If enabled, cjson will not throw exception when there are unsupported types
182in the Lua table.
183
184For example:
185
186```lua
187local ffi = require "ffi"
188local cjson = require "cjson"
189cjson.encode_skip_unsupported_value_types(true)
190local t = {key = "val"}
191
192t.cdata = ffi.new("char[?]", 100)
193print(cjson.encode(t))
194```
195
196This will generate:
197
198```json
199{"key":"val"}
200```
201
202[Back to TOC](#table-of-contents)
203
174decode_array_with_array_mt 204decode_array_with_array_mt
175-------------------------- 205--------------------------
176**syntax:** `cjson.decode_array_with_array_mt(enabled)` 206**syntax:** `cjson.decode_array_with_array_mt(enabled)`