]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix pretty-printing of {}
authorLars Ingebrigtsen <larsi@gnus.org>
Wed, 10 Jul 2019 11:23:43 +0000 (13:23 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 10 Jul 2019 11:23:47 +0000 (13:23 +0200)
* lisp/json.el (json-pretty-print): Fix reading {}, which returns nil.

lisp/json.el

index eae5eda783d840b29c73b54ba5db9e6a77b04ebf..d664dae05e4d9bc56fca294afa8cf799bc0a3cb6 100644 (file)
@@ -764,13 +764,15 @@ With prefix argument MINIMIZE, minimize it instead."
         (json-null :json-null)
         ;; Ensure that ordering is maintained
         (json-object-type 'alist)
+        (err (gensym))
         json)
     (save-restriction
       (narrow-to-region begin end)
       (goto-char begin)
-      (while (setq json (condition-case _
-                            (json-read)
-                          (json-error nil)))
+      (while (not (eq (setq json (condition-case _
+                                     (json-read)
+                                   (json-error err)))
+                      err))
         (delete-region begin (point))
         (insert (json-encode json))
         (setq begin (point))))))