0
  • how can i get the "Points" value using JsonConvert.DeserializeObject can anyone help me

    { "data": { "Gamers": [ { "id": "5397742571", "startTime": "Thu, 28 Jun 2022 00:04:13 GMT", "points": 11.647601, "hash": { "id": "xxxxxxxxxxxx", "hash": "xxxxxxxxxx", "__typename": "GamerRace" }, } ] }

2
  • Welcome to StackOverflow. Well, would recommend using tools such as json2csharp to convert the JSON to C# classes. Commented Jun 30, 2022 at 2:15
  • Why did you tag this question with [api] when the API tag description states: "DO NOT USE. Use specific tags like [google-cloud-platform], [facebook], [amazon-web-services] instead or [api-design] where applicable. Questions asking to recommend or find an API are off-topic." ? Also, none of those seem like they would be relevant to your question. Commented Jun 30, 2022 at 2:22

1 Answer 1

1

First of all. Your json have some issue. I fix it and here is it.

  {
  "data": {
           "Gamers": [
             { 
                "id": "5397742571",
                "startTime": "Thu, 28 Jun 2022 00:04:13 GMT",
                "points": 11.647601,
                "hash": {
                   "id": "xxxxxxxxxxxx",
                   "hash": "xxxxxxxxxx",
                   "__typename": "GamerRace"
                 }
              }
            ]
        }
    }

Now Create Model for this json like below.

public class Data
{
    public List<Gamer> Gamers { get; set; }
}

public class Gamer
{
    public string id { get; set; }
    public string startTime { get; set; }
    public double points { get; set; }
    public Hash hash { get; set; }
}

public class Hash
{
    public string id { get; set; }
    public string hash { get; set; }
    public string __typename { get; set; }
}

Now its time to convert your json into c# object.

Data people = JsonConvert.DeserializeObject<Data>(yourJson);

Hope it helps you buddy.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.