diff --git a/lisp/json.el b/lisp/json.el index eb655162d3..461f688f9c 100644 --- a/lisp/json.el +++ b/lisp/json.el @@ -199,6 +199,8 @@ json--with-output-to-string (with-current-buffer standard-output ;; This affords decent performance gains. (setq-local inhibit-modification-hooks t) + ;; Ignore `read-only' property once and for all (bug#43549). + (setq-local inhibit-read-only t) ,@body))) (defmacro json--with-indentation (&rest body) @@ -458,9 +460,9 @@ json-read-string (defun json--print-string (string &optional from) "Insert a JSON representation of STRING at point. FROM is the index of STRING to start from and defaults to 0." - (goto-char (prog1 (1+ (point)) - ;; Strip `read-only' property (bug#43549). - (insert ?\" (substring-no-properties string from)))) + (goto-char (prog1 (1+ (point)) (insert ?\" string))) + (set-text-properties (point) (point-max) ()) + (and from (delete-char from)) ;; Escape only quotation mark, backslash, and the control ;; characters U+0000 to U+001F (RFC 4627, ECMA-404). (while (re-search-forward (rx (in ?\" ?\\ cntrl)) nil 'move)