From 91ca29db9a4a4fd0eedaebcd5d5f3ba2ace5ae63 Mon Sep 17 00:00:00 2001 From: lijunlong Date: Thu, 1 Aug 2024 09:23:08 +0800 Subject: doc: added doc for encode_skip_unsupported_value_types. --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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 * [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 @@ -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)` -- cgit v1.2.3-55-g6feb