aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc/lua.txt
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/doc/lua.txt')
-rw-r--r--runtime/doc/lua.txt19
1 files changed, 16 insertions, 3 deletions
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index 1110fb7fc3..80ef2e358c 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -747,9 +747,22 @@ vim.json.encode({obj}) *vim.json.encode*
vim.json.decode({str}[, {opts}]) *vim.json.decode*
Decodes (or "unpacks") the JSON-encoded {str} to a Lua object.
- {opts} is a table with the key `luanil = { object: bool, array: bool }`
- that controls whether `null` in JSON objects or arrays should be converted
- to Lua `nil` instead of `vim.NIL`.
+ - Decodes JSON "null" as |vim.NIL| (controllable by {opts}, see below).
+ - Decodes empty object as |vim.empty_dict()|.
+ - Decodes empty array as `{}` (empty Lua table).
+
+ Example: >lua
+ :lua vim.print(vim.json.decode('{"bar":[],"foo":{},"zub":null}'))
+ --> { bar = {}, foo = vim.empty_dict(), zub = vim.NIL }
+<
+ Parameters: ~
+ • {str} Stringified JSON data.
+ • {opts} Options map keys:
+ • luanil: { object: bool, array: bool }
+ • `luanil.object=true` converts `null` in JSON objects to
+ Lua `nil` instead of `vim.NIL`.
+ • `luanil.array=true` converts `null` in JSON arrays to Lua
+ `nil` instead of `vim.NIL`.
------------------------------------------------------------------------------
VIM.SPELL *lua-spell*