text: ‘Paste JSON As Classes’ is a cool feature in ASP.NET and Web Tools 2012.2 RC. This feature will help you generate strongly typed classes in C# or VB.NET from valid JSON text.
  With ASP.NET and Web Tools 2012.2 RC installed, you will see new menu option like below for C#:
  { "link": "", /*Awesome*/ "virtual": "Virtual Keyboard", "partial": " The magnesium panels are finished with partial vapor deposition", "Price": 499.99, "title": "Microsoft Surface", "शीर्षक": "माइक्रोसॉफ्ट सरफेस", "Like": true, "cdDrive":null, }
  C# class for above JSON object will look like below.
  public class Rootobject { public string link { get; set; } public string _virtual { get; set; } public string partial { get; set; } public float Price { get; set; } public string title { get; set; } public string शीर्षक { get; set; } public bool Like { get; set; } public object cdDrive { get; set; } }
  VB.NET class will be like below
  Public Class Rootobject Public link As String Public virtual As String Public _partial As String Public Price As Single Public title As String Public शीर्षक As String Public _Like As Boolean Public cdDrive As Object End Class
  DateTime Formats
  JSON parser recognizes some DateTime formats as valid DateTime data types and some are not.
  Below JSON object has some valid DateTime data and some invalid DateTime data types
  [ { "DateTimeValid": "2012-05-03T00:06:00.638Z", "NullableDateTime": null, "DateTimeToString": "2009-07-31T00:00Z", "DateTimeToObject": "2012-05-03T00:06:00.638Z", }, { "DateTimeValid": "2012-05-03T00:06:00Z", "NullableDateTime": "2012-05-03T00:06:00.638Z", "DateTimeToString": "2009-07-31T00:00Z", "DateTimeToObject": "2012-05-03T00:06", } ]
  C# class for above JSON object will look like below.
  public class Rootobject { public Class1[] Property1 { get; set; } } public class Class1 { public DateTime DateTimeValid { get; set; } public DateTime? NullableDateTime { get; set; } public string DateTimeToString { get; set; } public object DateTimeToObject { get; set; } }.
  [ { "Name": "Kamal, Employee", "Manager": { "Name": "Barry, Manager" } }, { "Name": "Barry, Manager" } ]
  C# class for above JSON object will look like below.
  public class Rootobject { public Class1[] Property1 { get; set; } } public class Class1 { public string Name { get; set; } public Manager Manager { get; set; } } public class Manager { public string Name { get; set; } }
  VB. NET class as below
  Public Class Rootobject Public Property1() As Class1 End Class Public Class Class1 Public Name As String Public Manager As Manager End Class Public Class Manager Public Name As String End Class
  Multi-Dimensional Arrays
  You can convert multi-dimension JSON arrays to classes. JSON Example for two dimensional array:
  [ [ 1, 2, 3 ] ]
  C# class for above JSON object will look like below:
  public class Rootobject { public int[][] Property1 { get; set; } }
  VB.NET class:
  Public Class Rootobject Public Property1()() As Integer End Class
  Also you can convert JSON with objects having arrays inside array as shown in the example below
  { "results": [{ "address_Office": [{ "street_number": "One", "city_name": "Bellevue", "state_name": "Washington", "street_name": [ "Microsoft Way" ] }], }] }
  C# class for above JSON object will look like below:
  public class Rootobject { public Result[] results { get; set; } } public class Result { public Address_Office[] address_Office { get; set; } } public class Address_Office { public string street_number { get; set; } public string city_name { get; set; } public string state_name { get; set; } public string[] street_name { get; set; } }
  VB.NET class:
  Public Class Rootobject Public results() As Result End Class Public Class Result Public address_Office() As Address_Office End Class Public Class Address_Office Public street_number As String Public city_name As String Public state_name As String Public street_name() As String End).
  { "DecimalMax": 1.79769313486232E+308, }!
  Join the conversationAdd Comment
  Thanks for the information. This is very helpful!!!
  For "If property is a keyword in C#/VB.NET then it will be prepended with _ (underscore).", is there a reason why you didn't just use the "@" symbol to escape the reserved word?
  Can we have this for all projects, not just web? We have class libraries that do parsing too and this feature is sorely missed now that WE doesn't have it.
  Very nice. Will try it now.
  I would prefer to see the VB.Net classes with properties rather than public fields.
  Public Class Rootobject
  Public Property link As String
  Public Property virtual As String
  End Class
  Wow, thats super cool !
  Cool stuff! Very useful, very helpful, very Visual Studio!
  Awesome!
  Thank you all for taking time in reading this blog post and appreciate your valuable comments!
  @PeteGoo: There is no specific reason for using _(underscore) instead of "@".
  @Oren Novotny: We are working on your ask. No commitments here.
  @This is very cool but needs a consistency tweak: I have open up a bug for issue you mentioned and feature team will triage this for RTM release.
  @Shri: Do let us know your feedback once you try out this feature.
  Oren – not sure if it'll help you or not, but in the past I've used and the codeplex project it uses (jsonclassgenerator.codeplex.com) with success when needing to create a set of classes to deserialize a json object graph into memory. JSON.Net (and likely other deserializers) supports attributes for allowing mapping in case you want/need the C# property to be different in name than what's in the json.
  There's likely other tools out there to do the same as well, but those were 'good enough' for me at the time. 🙂
  thank you very much for this particular feature, i often find myself writing the js representations of my classes and this feature will save me a lot of time…..
  Hi, just wondering I couldn't see this menu option in VS2012?
  I can only see Paste XML as Classes. (using ver 2.2)
  @Samir, Thanks!
  @Dave, this option is visible only in web application projects and websites.
  Also make sure you have installed Web Tools 2012.2 RC.
  This is great, just one ask – could Lists be generated instead of arrays? Perhaps this could be configurable?
  I'm on Visual Studio 2012 English Version and Windows 8 x64 Chinese.
  When pasting json string, Visual Studio prompts:
  —————————
  Microsoft Visual Studio
  —————————
  The culture 'Chinese (Simplified, PRC)' is not supported. Pluralization is currently only supported for the English language.
  —————————
  确定
  —————————
  How to change the culture?
  @victorwoo, this issue is fixed in WTE 1.2 RTM which will be available soon.
  @Stuart Quinn, thanks for feedback. We will consider this feedback in future product release.
  The paste JSON as classes features should be made available in a WebApi project as well.
  @j Cory: Thanks for your comment. "ASP.NET and Web Tools 2012.2 RTM" will enable this action on all projects!
  excelente tip!!!
  FYI, There is a bug in this feature for VB.NET (I'm using VS 2013 as well). When the feature generates code for an array, it generates something like "Public Property accounts() As Account". While the syntax is correct for regular declarations, if declared like this for a Property, it is not actually an array. The correct syntax is "Public Property accounts As Account()". I have to manually change this to the correct syntax each time I use the feature, or change it to List(Of…).
  All that is missing is adding JsonProperty attributes and converting properties to PascalCase…