diff options
| author | Simen Heggestøyl | 2015-11-12 18:30:37 +0100 |
|---|---|---|
| committer | Simen Heggestøyl | 2015-11-12 18:30:37 +0100 |
| commit | 1e363a8ea5ac09455f3a44fbb646b5af32bca51c (patch) | |
| tree | 7b9ab75057951d32892cb50a31c5880c941caf23 /etc | |
| parent | 9dd7da9945c16aa343080a535ed74eeecf769fd1 (diff) | |
| download | emacs-1e363a8ea5ac09455f3a44fbb646b5af32bca51c.tar.gz emacs-1e363a8ea5ac09455f3a44fbb646b5af32bca51c.zip | |
Enable sorting of JSON object keys when encoding
* lisp/json.el (json-encoding-object-sort-predicate): New variable for
specifying a sorting predicate for JSON objects during encoding.
(json--plist-to-alist): New utility function.
(json-encode-hash-table): Re-use `json-encode-alist' when object keys
are to be sorted.
(json-encode-alist): Sort output by
`json-encoding-object-sort-predicate, when set.
(json-encode-plist): Re-use `json-encode-alist' when object keys are
to be sorted.
(json-pretty-print-buffer-ordered): New command to pretty print the
buffer with object keys sorted alphabetically.
(json-pretty-print-ordered): New command to pretty print the region with
object keys sorted alphabetically.
* test/automated/json-tests.el (test-json-plist-to-alist)
(test-json-encode-plist, test-json-encode-hash-table)
(test-json-encode-alist-with-sort-predicate)
(test-json-encode-plist-with-sort-predicate): New tests.
* etc/NEWS: Add an entry for the new commands.
Diffstat (limited to 'etc')
| -rw-r--r-- | etc/NEWS | 4 |
1 files changed, 4 insertions, 0 deletions
| @@ -332,6 +332,10 @@ unlike `bookmark-set' which silently updates an existing bookmark. | |||
| 332 | --- | 332 | --- |
| 333 | *** `json-pretty-print' and `json-pretty-print-buffer' now maintain | 333 | *** `json-pretty-print' and `json-pretty-print-buffer' now maintain |
| 334 | the ordering of object keys by default. | 334 | the ordering of object keys by default. |
| 335 | --- | ||
| 336 | *** New commands `json-pretty-print-ordered' and | ||
| 337 | `json-pretty-print-buffer-ordered' pretty prints JSON objects with | ||
| 338 | object keys sorted alphabetically. | ||
| 335 | 339 | ||
| 336 | ** You can recompute the VC state of a file buffer with `M-x vc-refresh-state' | 340 | ** You can recompute the VC state of a file buffer with `M-x vc-refresh-state' |
| 337 | ** Prog mode has some support for multi-mode indentation. | 341 | ** Prog mode has some support for multi-mode indentation. |