1

I am getting response of JSON like this.

{
"serp":
    {
        "1":
        {
            "href": "href1.com",
            "url": "url1.com"
        },
        "2":
        {
            "href": "href2.com",
            "url": "url2.com"
        }
     }
  }

When I am trying to map with .net class it doesn't allow me to create class like public class 1 or public class 2. I want this 1 and 2 value as rank and also I want href and url value too. So how can I get this by creating class structure?

Thank in advance.

Prashant Srivastav
  • 1,723
  • 17
  • 28
Nikunj Soni
  • 297
  • 2
  • 13

1 Answers1

0

This answer demonstrates a solution that might be applied to your problem using a dictionary object. You can create a class like this (just an example):

public class ExampleObject
{
    public string href { get; set; }
    public string url { get; set; }
}

and use those objects in a dictionary as a value, while the key is of type Integer. This would allow to sort by the key and access the information stored in url and href.

Community
  • 1
  • 1
Paul M.
  • 82
  • 1
  • 7