Skip to content

Commit 91ca29d

Browse files
doc: added doc for encode_skip_unsupported_value_types.
1 parent b0b4c58 commit 91ca29d

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Table of Contents
1515
* [empty_array_mt](#empty_array_mt)
1616
* [encode_number_precision](#encode_number_precision)
1717
* [encode_escape_forward_slash](#encode_escape_forward_slash)
18+
* [encode_skip_unsupported_value_types](#encode_skip_unsupported_value_types)
1819
* [decode_array_with_array_mt](#decode_array_with_array_mt)
1920

2021
Description
@@ -171,6 +172,35 @@ If disabled, forward slash '/' will be encoded as '/' (no escape is applied).
171172

172173
[Back to TOC](#table-of-contents)
173174

175+
encode_skip_unsupported_value_types
176+
---------------------------
177+
**syntax:** `cjson.encode_skip_unsupported_value_types(enabled)`
178+
179+
**default:** false
180+
181+
If enabled, cjson will not throw exception when there are unsupported types
182+
in the Lua table.
183+
184+
For example:
185+
186+
```lua
187+
local ffi = require "ffi"
188+
local cjson = require "cjson"
189+
cjson.encode_skip_unsupported_value_types(true)
190+
local t = {key = "val"}
191+
192+
t.cdata = ffi.new("char[?]", 100)
193+
print(cjson.encode(t))
194+
```
195+
196+
This will generate:
197+
198+
```json
199+
{"key":"val"}
200+
```
201+
202+
[Back to TOC](#table-of-contents)
203+
174204
decode_array_with_array_mt
175205
--------------------------
176206
**syntax:** `cjson.decode_array_with_array_mt(enabled)`

0 commit comments

Comments
 (0)