diff options
| author | skewb1k <skewb1kunix@gmail.com> | 2025-09-14 07:17:07 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-13 21:17:07 -0700 |
| commit | a897cc17a5ee9a3bf9a22eb105b15d2c162f7176 (patch) | |
| tree | 034f6b2fde48b218e3550106baa311fc5321aaa7 /runtime/lua/vim/_meta/json.lua | |
| parent | 05a511996fd411b52904cf78eb1694abfa34351e (diff) | |
| download | rneovim-a897cc17a5ee9a3bf9a22eb105b15d2c162f7176.tar.gz rneovim-a897cc17a5ee9a3bf9a22eb105b15d2c162f7176.tar.bz2 rneovim-a897cc17a5ee9a3bf9a22eb105b15d2c162f7176.zip | |
feat(json): vim.json.encode() sort_keys #35574
Problem: There is no way to ensure a stable key order when encoding a JSON string,
which can be useful for comparisons and producing cleaner diffs.
Solution: Introduce a `sort_keys` option for `vim.json.encode()`,which
is disabled by default. When enabled, object keys are sorted in
alphabetical order.
Diffstat (limited to 'runtime/lua/vim/_meta/json.lua')
| -rw-r--r-- | runtime/lua/vim/_meta/json.lua | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/runtime/lua/vim/_meta/json.lua b/runtime/lua/vim/_meta/json.lua index 8d3e054833..a149d24dec 100644 --- a/runtime/lua/vim/_meta/json.lua +++ b/runtime/lua/vim/_meta/json.lua @@ -56,5 +56,7 @@ function vim.json.decode(str, opts) end --- 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. +--- - sort_keys: (boolean) (default false) Sort object +--- keys in alphabetical order. ---@return string function vim.json.encode(obj, opts) end |