mirror of
https://github.com/neovim/neovim.git
synced 2025-12-15 19:05:40 +00:00
feat(json): pretty-format (indent) with vim.json.encode() #35424
Problem: There is no straightforward way to pretty-print objects as JSON. The existing `vim.inspect` outputs LON. Solution: Introduce an `indent` option for `vim.json.encode()` which enables human-readable output with configurable indentation. Adapts PR to upstream: openresty/lua-cjson#114
This commit is contained in:
@@ -38,5 +38,7 @@ function vim.json.decode(str, opts) end
|
||||
---@param opts? table<string,any> Options table with keys:
|
||||
--- - escape_slash: (boolean) (default false) Escape slash
|
||||
--- characters "/" in string values.
|
||||
--- - indent: (string) (default "") String used for indentation at each nesting level.
|
||||
--- If non-empty enables newlines and a space after colons.
|
||||
---@return string
|
||||
function vim.json.encode(obj, opts) end
|
||||
|
||||
Reference in New Issue
Block a user