2

I have a json like this

{"1":"#ff0051","2":"#d000ff","3":"#2200ff","4":"#00ff59"}

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

Jonathan Nixon
  • 4,940
  • 5
  • 39
  • 53
Kanishka
  • 267
  • 4
  • 21

1 Answers1

2

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

Console.WriteLine(o["1"]);

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

Niyoko
  • 7,512
  • 4
  • 32
  • 59