Monday, January 7, 2013

JSON Syntax Highlighting And Validation For Visual Studio

The extension TextHighlighterExtension for Visual Studio 2010 and 2012 now support JSON color coding and validation on the fly. By default the JSON validation is strict, but can be turn into a more relax mode where trailing comma, property name as id and // comment are supported.
Even in strict mode the /* */ comments are supported though it is not strictly JSON.




Colors Customizations

The extension comes with default colors set for black and white background.
If you want to customize the colors goto to the folder:  

Visual Studio 2010:

C:\Users\[USER-NAME]\AppData\Local\Microsoft\VisualStudio\10.0\Extensions\Frederic Torres\TextHighlighterExtension\2.0 

Visual Studio 2012:

C:\Users\[USER-NAME]\AppData\Local\Microsoft\VisualStudio\11.0\Extensions\gpfoku5l.btj

Open the file Colors.htm in Internet Explorer to visualize the color names available.
Update the file COLORS_DEFINITION.js to change the colors.
To reset the colors delete the file Config.json.

\\


JSON Standard
The extension offer JSON Syntax Validation



In the extension v 2.0 the following are accepted but are not part of the JSON standard
  • /* */ comment
  • If the first comment contains "use relax" (with the double quote), property names do not have to be string but can be id name like in JavaScript. Trailing coma are accepted.

How to install the extension

Menu: Tools -> Extension Manager





4 comments:

  1. Actually the download of TextHighlighter seems to be risky, because...

    "This request is blocked by the SonicWALL Gateway Anti-Virus Service. Name: Fynloski.A_26 (Trojan)"

    Do you have any idea?

    Kristof

    ReplyDelete
  2. New JSON editor added in Visual Studio 2013 Update 2 CTP2 - http://blogs.msdn.com/b/webdev/archive/2014/02/28/new-json-editor-features-in-visual-studio-2013-update-2-ctp2.aspx

    ReplyDelete
    Replies
    1. If JSON support is only in the CTP should I remove JSON support from my extension?
      What do you think?

      Delete