json-emacs/json-mode

beautify-json hardcodes indent level

Closed this issue · 7 comments

beautify-json hardcodes indent=4, but it should use js-indent-level.

+1

Closing this now that we're using json-reformat as in #20

This still doesn't work correctly, as json-reformat also hardcodes 4.

Hm you're right - let's see if we can fix that

Hi. @petere @joshwnj

json-reformat:indent-width has been implemented in json-reformat

Example

{"name": "John Smith", "age": 33, "info": {"eat": "pizza", "sport": "soccer"}}
(setq json-reformat:indent-width 4) ;; default
;; {
;;     "info": {
;;         "sport": "soccer",
;;         "eat": "pizza"
;;     },
;;     "age": 33,
;;     "name": "John Smith"
;; }

(setq json-reformat:indent-width 12)
;; {
;;             "info": {
;;                         "sport": "soccer",
;;                         "eat": "pizza"
;;             },
;;             "age": 33,
;;             "name": "John Smith"
;; }

Try it! 🍕

This is great @gongo, thanks!

I think this still doesn't work, because json-reformat:indent-width is not set to js-indent-level anywhere.