diff options
| author | lijunlong <lijunlong@openresty.com> | 2024-08-01 09:23:08 +0800 |
|---|---|---|
| committer | lijunlong <lijunlong@openresty.com> | 2024-08-01 09:23:44 +0800 |
| commit | 91ca29db9a4a4fd0eedaebcd5d5f3ba2ace5ae63 (patch) | |
| tree | cb3dacd8df87900d92eb154546b7691f31f3110e | |
| parent | b0b4c58df8fba8f7ea36c69bbdb517f9732b1bcf (diff) | |
| download | lua-cjson-91ca29db9a4a4fd0eedaebcd5d5f3ba2ace5ae63.tar.gz lua-cjson-91ca29db9a4a4fd0eedaebcd5d5f3ba2ace5ae63.tar.bz2 lua-cjson-91ca29db9a4a4fd0eedaebcd5d5f3ba2ace5ae63.zip | |
doc: added doc for encode_skip_unsupported_value_types.2.1.0.14
| -rw-r--r-- | README.md | 30 |
1 files changed, 30 insertions, 0 deletions
| @@ -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 | ||
| 20 | Description | 21 | Description |
| @@ -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 | ||
| 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 | |||
| 174 | decode_array_with_array_mt | 204 | decode_array_with_array_mt |
| 175 | -------------------------- | 205 | -------------------------- |
| 176 | **syntax:** `cjson.decode_array_with_array_mt(enabled)` | 206 | **syntax:** `cjson.decode_array_with_array_mt(enabled)` |
