Hi,
Paste you JSON string into the following tool:
json2csharp[
^], this will generate a c# class for you.
I am assuming you are not using JSON.NET. If this the case, then you can
try it[
^].
It has the following features -
1. LINQ to JSON
2. The JsonSerializer for quickly converting your .NET objects to JSON and back again
3. Json.NET can optionally produce well formatted, indented JSON for debugging or display
4. Attributes like JsonIgnore and JsonProperty can be added to a class to customize how a class is serialized
5. Ability to convert JSON to and from XML
6.Supports multiple platforms: .NET, Silverlight and the Compact Framework
Look at the
example[
^] below. In this example,
JsonConvert[
^] object is used to convert an object to and from JSON. It has two static methods for this purpose. They are
SerializeObject(Object obj)[
^] and
DeserializeObject<t>(String json)[
^] -
Product product = new Product();
product.Name = "Apple";
product.Expiry = new DateTime(2008, 12, 28);
product.Price = 3.99M;
product.Sizes = new string[] { "Small", "Medium", "Large" };
string json = JsonConvert.SerializeObject(product);
Product deserializedProduct = JsonConvert.DeserializeObject<product>(json);