DotNet Mirror
  DNM facebook   DNM Google+   DNM Twitter   

JSON Debugger Visualizer in Visual Studio 2013

By Ashok Nalam on 06 Mar 2014 | Category: Visual Studio | Tagged: JSON visual studio 2013 .NET 
Microsoft has added "JSON Visualizer" to Visual Studio debugger With Visual Studio 2013 Update 2. This post shows different features of JSON Visualizer with sample C# example.
  Discuss Add Comment   |  
Add rating Rate this resource   

Introduction

JSON (JavaScript Object Notation) is an open standard format to transfer data between server and client applications. Its kind of an alternative to XML format and used mostly in current development. Due to more usage of JSON in projects, Microsoft has added "JSON Visualizer" to Visual Studio debugger  With Visual Studio 2013 Update 2.

This post shows what are the features of JSON Visualizer with sample C# example.

Sample JSON:

{
  "array": [
    1,
    2,
    3
  ],
  "boolean": true,
  "null": null,
  "number": 456,
  "object": {
    "a": "b",
    "c": "d",
    "e": "f"
  },
  "string": "Hello World"
}

C# Example:

We have copied above sample JSON data to string variable "sampleJSON" and try to see features of JSON Visualizer.
namespace DotNetMirror
{
    class JSONVisualizerDemo
    {
        public static void Main()
        {
            string sampleJSON = "{\"array\":[1,2,3],\"boolean\":true,\"null\":null,\"number\":123,\"object\":{\"a\":\"b\",\"c\":\"d\",\"e\":\"f\"},\"string\":\"Hello World\"}";

        }
    }
}

Where to see JSON Visualizer:

JSON Visualizer comes in debugging mode of your application. Click the search icon that appears next to a variable name in DataTips/Watch/Autos/Locals/Quick Watch window. You can find list of visualizers, out of which you can choose JSON Visualizer.

Getting JSON Visualizer from DataTips
Fig#1 : Getting JSON Visualizer from DataTips

Getting JSON Visualizer from Autos
Fig#2 : Getting JSON Visualizer from Autos

Getting JSON Visualizer from Immediate Window
Fig#3 : Getting JSON Visualizer from Immediate Window

Now we know how to invoke JSON Visualizer and below we will see features of it.

Feature#1 : Shows JSON encoded strings in a TreeView format

We can see the JSON objects data as TreeView format. It will be simpler and useful if we have large JSON data.

JSON Data Objects in TreeView format
Fig#4 : JSON Data Objects in TreeView format

Feature#2 :Search and Highlight string

If we have large amount of JSON data, with search feature it automatically hightlight the matched occurances.

JSON Visualizer with Search and Highlight
Fig#5 : JSON Visualizer with Search and Highlight

Feature#3 : copy path, key value and Item 

You can right click on particular object and copy path/key/value/Item.

JSON Visualizer Copy Data
Fig#6 : JSON Visualizer Copy Data

Feature#4 : Validates JSON - String is not JSON Formatted

If we have any invalid string in JSON data then JSON Visualizer shows as "String is not JSON Formatted" error. In the below image you can see we have added test keyword before brace.

JSON Visualizer with validation check
Fig#7 : JSON Visualizer with validation check

Note: JSON visualizer works for all languages and project types currently supported by Visual Studio debugger (C#.NET, VB.NET, C++, JavaScript, etc.)
  Discuss Add Comment    
Add rating Rate this resource   
About the Contributor
Member Since : 10 Dec 2012
Member Points (Level) : 9526  (Professional)
Location : INDIA
Home Page : http://dotnetmirror.com
About : I am admin of this site.
Rate this resource
 
Add your Comment
Name Email WebSite
Captcha Refresh


Comments (0)
No comments found, click here to add comment.
 
cheap jordans|wholesale air max|wholesale jordans|wholesale jewelry|wholesale jerseys