I had the same problem and discovered that you should have valid JSON text in your clipboard.
Steps to get it to work:
- Install Web Essentials for your version of VS (Visual Studio). Web Essentials Download page
- Create empty class file in VS.
- Copy valid JSON text into clipboard.
- You will now see the "Paste Json as Classes" under Edit -> Paste Special -> Paste Json as Classes
Sample input:
{
"firstName":"John",
"lastName":"Smith",
"age":25,
"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"
}
]
}
Sample output:
public class Rootobject
{
public string firstName { get; set; }
public string lastName { get; set; }
public int age { get; set; }
public Address address { get; set; }
public Phonenumber[] phoneNumber { get; set; }
}
public class Address
{
public string streetAddress { get; set; }
public string city { get; set; }
public string state { get; set; }
public string postalCode { get; set; }
}
public class Phonenumber
{
public string type { get; set; }
public string number { get; set; }
}