chast chast - 1 year ago 125
JSON Question

C# Json deserialize - property as variable

I have problem. From json: I would like to get property name as variable. Can I do it with Newtonsoft Json library? Thanks in advance for help.

Answer Source

You can deserialize this JSON into a Dictionary<string, decimal> like this:

var prices = JsonConvert.DeserializeObject<Dictionary<string, decimal>>(json);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download