tags:

views:

2071

answers:

4

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.

+1  A: 

If you can't find a JSON-specific mode, try one of the many Javascript modes, since JSON is after all really just Javascript:

Google search for Javascript mode in Emacs

Don Wakefield
+7  A: 

Have you tried Steve Yegge's js2-mode for Emacs?

J.F. Sebastian
JSON is not really supported by js2-mode, though.http://code.google.com/p/js2-mode/issues/detail?id=50
Török Gábor
A: 

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);
p4bl0
To be exact, the example you provided ain't JSON but the JavaScript object literal, which is similar but different.
Török Gábor
A: 

JSON is supported by espresso-mode

逸飞
I can only get espresso-mode to work with legal Javascript syntax. JSON expressions don't, for example, get indented properly.
ESV