The response to my web request coming as the following (not under my control):
{
"nasdaq_imbalance":
{
"name": "nasdaq_imbalance",
"group": "Market Data",
"description": null
},
"DXOpen IM":
{
"name": "DXOpen IM",
"group": "Daily",
"description": null
},
"Float Shares":
{
"name": "Float Shares",
"group": "Daily",
"description": null
},
}
Somehow, I need to deserialize that into C# object that contains a list of objects... Basically I need a list of objects like that:
public class Dataset {
public string name { get; set; }
public string group { get; set; }
public string description { get; set; }
}
A common way to deserialize JSON is to first create a class with properties and fields that represent one or more of the JSON properties. Then, to deserialize from a string or a file, call the JsonSerializer. Deserialize method.
JSON is a format that encodes objects in a string. Serialization means to convert an object into that string, and deserialization is its inverse operation (convert string -> object).
In Deserialization, it does the opposite of Serialization which means it converts JSON string to custom . Net object. In the following code, it creates a JavaScriptSerializer instance and calls Deserialize() by passing JSON data. It returns a custom object (BlogSites) from JSON data.
If you are using Json.NET, you can use JsonConvert.DeserializeObject<Dictionary<string, Dataset>>(json)
and the keys of the dictionary will be nasdaq_imbalance
, DXOpen IM
, Float Shares
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With