I'm using GNU Emacs 28.0.50 and when I use the json-pretty-print-buffer function in a JSON file, the content of the file are removed with "Expecting value" as a message.
Example:
My configuration:
(use-package json-mode
:delight "J "
:mode "\\.json\\'"
:hook (before-save . my/json-mode-before-save-hook)
:preface
(defun my/json-mode-before-save-hook ()
(when (eq major-mode 'json-mode)
(json-pretty-print-buffer)))
(defun my/json-array-of-numbers-on-one-line (encode array)
"Prints the arrays of numbers in one line."
(let* ((json-encoding-pretty-print
(and json-encoding-pretty-print
(not (loop for x across array always (numberp x)))))
(json-encoding-separator (if json-encoding-pretty-print "," ", ")))
(funcall encode array)))
:config (advice-add 'json-encode-array :around #'my/json-array-of-numbers-on-one-line))
Hey,
I'm using GNU Emacs 28.0.50 and when I use the
json-pretty-print-buffer
function in a JSON file, the content of the file are removed with "Expecting value" as a message.Example:
My configuration:
Do you have any idea what the problem is?
Thank you for your work.