JSON Syntax Highlighting?

Discuss syntax highlighting or submit new syntax files.
Post Reply
User avatar
rjbill
Posts: 830
Joined: 13 Jun 2011 06:36

JSON Syntax Highlighting?

Post 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.
RJTE version 14.64 (actual) - 64-bit
Win 10 Pro 64-bit 8 GB RAM Intel Core i7-6700 3.40 GHz SCSI Hard Drive 1 TB

Note: The signature is dynamic, not static,
so it may not show the correct version above
that was in use at the time of the post.

hamasaki
Posts: 69
Joined: 14 Mar 2012 14:15

Re: JSON Syntax Highlighting?

Post 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.

User avatar
rjbill
Posts: 830
Joined: 13 Jun 2011 06:36

Re: JSON Syntax Highlighting?

Post 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/
RJTE version 14.64 (actual) - 64-bit
Win 10 Pro 64-bit 8 GB RAM Intel Core i7-6700 3.40 GHz SCSI Hard Drive 1 TB

Note: The signature is dynamic, not static,
so it may not show the correct version above
that was in use at the time of the post.

Post Reply