Page 1 of 1

JSON Syntax Highlighting?

Posted: 22 Oct 2012 08:48
by rjbill
I was looking for a JSON syntax file and couldn't find one.

Is that even possible?

I'm not real familiar with JSON.

There might not be any "keywords".
It might all be quoted text and punctuation highlighting.
Which might be better than nothing.

Re: JSON Syntax Highlighting?

Posted: 12 Jan 2013 12:43
by hamasaki
I don`t think json benefits from a highlighter. I have the Json Viewer as an integrated tool, so if I need to view the json structure easily I use that:
http://jsonviewer.codeplex.com/

Json is extremely useful and very easy to work with.

Re: JSON Syntax Highlighting?

Posted: 12 Jan 2013 21:55
by rjbill
Thanks. That's a nice tool.

But I like to use the editor to do JSON stuff.
I was going to make a highlighter and I didn't.
It would be pretty easy, though.
Although you could probably just use JavaScript highlighting
in a pinch, as better than nothing.

Here is an online highlighter and formatter:

http://jsonsh.com/

It could use a little better highlighting than that.
I think square brackets and braces should be different colors
to make them stand out more. And commas.
I would also make the quotes a different color from the
quoted text.

I've also seen some nice suggestions, like:

Make strings using single quotes show as errors.

Here's some JSON to try in it:

Code: Select all

{
  "firstName": "John",
  "lastName": "Smith",
  "age": 25,
  "alive": true,
  "address": {
    "streetAddress": "21 2nd Street",
    "city": "New York",
    "state": "NY",
    "postalCode": "10021"
  },
  "phoneNumber": [
    {
      "type": "home",
      "number": "212 555-1234"
    },
    {
      "type": "fax",
      "number": "646 555-4567"
    }
  ]
}
This site lets you view syntax highlighted HTML, and offers the user
the ability to choose what syntax highlighting scheme to use.

http://json-rpc.org/prefs/pygments

That would be a nice option for RJTE someday, the ability to name
highlighting schemes and offer them and allow their use and
installation and then let the user choose which scheme they want.
So, for example, as in the above page, people could publish
their different named highlighting schemes and the user could
choose the one they want to use.


The Chrome browser has addons that do syntax highlighting and maybe
formatting. Firefox probably has something like that, too.

http://www.londatiga.net/it/four-best-c ... ding-json/

And there are some nice JavaScript highlighter programs that let you highlight code
on web pages now, but most of them are fairly slow, especially for code of
any real size.

http://softwaremaniacs.org/soft/highlight/en/