aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-07-10 13:23:43 +0200
committerLars Ingebrigtsen2019-07-10 13:23:47 +0200
commitb93bde184e1e0d21bde34a7fd660888bd04893d7 (patch)
tree8a489c959b346d53042059510be7943e10e38f54
parentc198ecda9f51c3bc35d9709d0dc2c4b87ec4ee6e (diff)
downloademacs-b93bde184e1e0d21bde34a7fd660888bd04893d7.tar.gz
emacs-b93bde184e1e0d21bde34a7fd660888bd04893d7.zip
Fix pretty-printing of {}
* lisp/json.el (json-pretty-print): Fix reading {}, which returns nil.
-rw-r--r--lisp/json.el8
1 files changed, 5 insertions, 3 deletions
diff --git a/lisp/json.el b/lisp/json.el
index eae5eda783d..d664dae05e4 100644
--- a/lisp/json.el
+++ b/lisp/json.el
@@ -764,13 +764,15 @@ With prefix argument MINIMIZE, minimize it instead."
764 (json-null :json-null) 764 (json-null :json-null)
765 ;; Ensure that ordering is maintained 765 ;; Ensure that ordering is maintained
766 (json-object-type 'alist) 766 (json-object-type 'alist)
767 (err (gensym))
767 json) 768 json)
768 (save-restriction 769 (save-restriction
769 (narrow-to-region begin end) 770 (narrow-to-region begin end)
770 (goto-char begin) 771 (goto-char begin)
771 (while (setq json (condition-case _ 772 (while (not (eq (setq json (condition-case _
772 (json-read) 773 (json-read)
773 (json-error nil))) 774 (json-error err)))
775 err))
774 (delete-region begin (point)) 776 (delete-region begin (point))
775 (insert (json-encode json)) 777 (insert (json-encode json))
776 (setq begin (point)))))) 778 (setq begin (point))))))