Kanishka Kanishka -4 years ago 215
C# Question

json deserialize array without a property name

I have a json like this


How can I read these values since they don't have a property name? It is a bit difficult to think of a way.

Answer Source

Use JSON.Net

var s = "{\"1\":\"#ff0051\",\"2\":\"#d000ff\",\"3\":\"#2200ff\",\"4\":\"#00ff59\"}";
var o = JObject.Parse(s);

Then you can read the property value


Please note that you also need to install Json.NET Nuget Package.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download