diff options
Diffstat (limited to 'meta/3rd/OpenResty/library/cjson.safe.lua')
-rw-r--r-- | meta/3rd/OpenResty/library/cjson.safe.lua | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/meta/3rd/OpenResty/library/cjson.safe.lua b/meta/3rd/OpenResty/library/cjson.safe.lua new file mode 100644 index 00000000..64244b15 --- /dev/null +++ b/meta/3rd/OpenResty/library/cjson.safe.lua @@ -0,0 +1,46 @@ +---@meta + +--- The `cjson.safe` module behaves identically to the `cjson` module, except when +--- errors are encountered during JSON conversion. On error, the `cjson.safe.encode` +--- and `cjson.safe.decode` functions will return `nil` followed by the error message. +--- +--- @see cjson +--- +---@class cjson.safe : cjson +local cjson_safe = {} + + +--- unserialize a json string to a lua value +--- +--- Returns `nil` and an error string when the input cannot be decoded. +--- +--- ```lua +--- local value, err = cjson_safe.decode(some_json_string) +--- ``` +---@param json string +---@return any? decoded +---@return string? error +function cjson_safe.decode(json) end + + +--- serialize a lua value to a json string +--- +--- Returns `nil` and an error string when the input cannot be encoded. +--- +--- ```lua +--- local json, err = cjson_safe.encode(some_lua_value) +--- ``` +---@param value any +---@return string? encoded +---@return string? error +function cjson_safe.encode(value) end + + +--- instantiate an independent copy of the Lua CJSON module +--- +--- The new module has a separate persistent encoding buffer, and default settings +---@return cjson.safe +function cjson_safe.new() end + + +return cjson_safe |