Emacs mode to edit JSON

Viewed 30214

Does anybody know a good Emacs mode to edit JSON? An app I am working on uses a JSON based communication protocol and having the data nicely indented and syntax-highlighted would help me a lot in the process of figuring it out.

12 Answers

I would also recommand js2-mode.

JSON stands for JavaScript Object Notation. It's not another language and it's even not a data container like yaml or xml are. JSON could be used as a data container if there's no function (or in this case we should say method) inside a JSON object, but it's not the primary goal of JSON :-)

var myJSObject = {
  attr: {foo: "bar", baz: ["quux", "truc", "pouet"]},
  fooAlert: function (num) {
    alert(this.attr.foo+' '+num);
  }
};
myJSObject.fooAlert(42);
Related