diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-07-01 15:26:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-01 15:26:39 +0800 |
commit | cbcac3afc40268eae82a41a82248d912b1cfeeb6 (patch) | |
tree | 20a11fc7abda707b2ab63f4e262bea957dea30c3 /meta/3rd/OpenResty/library/cjson.safe.lua | |
parent | e58260200a9483f1e5095fafec8ebccb4ae71d5b (diff) | |
parent | ca2049011d13499e7204ed79a84c9fefef1b2e90 (diff) | |
download | lua-language-server-cbcac3afc40268eae82a41a82248d912b1cfeeb6.zip |
Merge pull request #1265 from flrgh/chore/resty-annotations
OpenResty type annotation updates
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 |