summaryrefslogtreecommitdiff
path: root/meta/3rd/OpenResty/library/cjson.safe.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-07-01 15:26:39 +0800
committerGitHub <noreply@github.com>2022-07-01 15:26:39 +0800
commitcbcac3afc40268eae82a41a82248d912b1cfeeb6 (patch)
tree20a11fc7abda707b2ab63f4e262bea957dea30c3 /meta/3rd/OpenResty/library/cjson.safe.lua
parente58260200a9483f1e5095fafec8ebccb4ae71d5b (diff)
parentca2049011d13499e7204ed79a84c9fefef1b2e90 (diff)
downloadlua-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.lua46
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