From b93bde184e1e0d21bde34a7fd660888bd04893d7 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Wed, 10 Jul 2019 13:23:43 +0200 Subject: [PATCH] Fix pretty-printing of {} * lisp/json.el (json-pretty-print): Fix reading {}, which returns nil. --- lisp/json.el | 8 +++++--- 1 file 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." (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)))))) -- 2.39.5