From e2f50c2eb1bbe4465a2f7f92c58f285ef0d6f75f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Diot?= Date: Fri, 30 Aug 2024 11:10:53 +0200 Subject: [PATCH] Squashed 'src/deps/src/lua-cjson/' changes from f95cd9ea1e..91ca29db9a 91ca29db9a doc: added doc for encode_skip_unsupported_value_types. b0b4c58df8 doc: add comment for dtoa.c. 42ee52e79e doc: update location of cjson documentation. REVERT: f95cd9ea1e doc: add comment for dtoa.c. git-subtree-dir: src/deps/src/lua-cjson git-subtree-split: 91ca29db9a4a4fd0eedaebcd5d5f3ba2ace5ae63 --- README.md | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4655a9add..debe1ae8c 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Table of Contents * [empty_array_mt](#empty_array_mt) * [encode_number_precision](#encode_number_precision) * [encode_escape_forward_slash](#encode_escape_forward_slash) + * [encode_skip_unsupported_value_types](#encode_skip_unsupported_value_types) * [decode_array_with_array_mt](#decode_array_with_array_mt) Description @@ -24,7 +25,7 @@ This fork of [mpx/lua-cjson](https://github.com/mpx/lua-cjson) is included in the [OpenResty](https://openresty.org/) bundle and includes a few bugfixes and improvements, especially to facilitate the encoding of empty tables as JSON Arrays. -Please refer to the [lua-cjson documentation](http://www.kyne.com.au/~mark/software/lua-cjson.php) +Please refer to the [lua-cjson documentation](https://kyne.au/~mark/software/lua-cjson.php) for standard usage, this README only provides informations regarding this fork's additions. See [`mpx/master..openresty/master`](https://github.com/mpx/lua-cjson/compare/master...openresty:master) @@ -171,6 +172,35 @@ If disabled, forward slash '/' will be encoded as '/' (no escape is applied). [Back to TOC](#table-of-contents) +encode_skip_unsupported_value_types +--------------------------- +**syntax:** `cjson.encode_skip_unsupported_value_types(enabled)` + +**default:** false + +If enabled, cjson will not throw exception when there are unsupported types +in the Lua table. + +For example: + +```lua +local ffi = require "ffi" +local cjson = require "cjson" +cjson.encode_skip_unsupported_value_types(true) +local t = {key = "val"} + +t.cdata = ffi.new("char[?]", 100) +print(cjson.encode(t)) +``` + +This will generate: + +```json +{"key":"val"} +``` + +[Back to TOC](#table-of-contents) + decode_array_with_array_mt -------------------------- **syntax:** `cjson.decode_array_with_array_mt(enabled)`