json-emacs/json-mode

Does not work well with non-ASCII

jarl-dk opened this issue · 2 comments

Please apply this patch to make it work with non-ascii:

diff --git a/json-mode.el b/json-mode.el
index f837c7b..6933bb4 100644
--- a/json-mode.el
+++ b/json-mode.el
@@ -26,7 +26,7 @@
   (let ((b (if mark-active (min (point) (mark)) (point-min)))
         (e (if mark-active (max (point) (mark)) (point-max))))
     (shell-command-on-region b e
-     "python -mjson.tool" (current-buffer) t)))
+     "python -c 'import sys,json; data=json.loads(sys.stdin.read()); print json.dumps(data,sort_keys=True,indent=4).decode(\"unicode_escape\").encode(\"utf8\",\"replace\")'" (current-buffer) t)))

 (define-derived-mode json-mode javascript-mode "JSON"
   "Major mode for editing JSON files"

See http://stackoverflow.com/a/7934783/300632 for reason.

Thanks Jarl! I'll take a look.

Updated. Thanks @jarl-dk