2

I have this JSON, and I'm trying to get each name, and place id, creator name, etcetera from the JSON data, I haven't figured out how to, I am using Newtonsoft.Json so then I will be able to write them in the console together.

Here's the JSON

{
  "games": [
    {
      "creatorId": 209596022,
      "creatorType": "User",
      "totalUpVotes": 12,
      "totalDownVotes": 1,
      "universeId": 2044766328,
      "name": "Char les Calvin Memorial",
      "placeId": 5764830729,
      "playerCount": 0,
      "price": null,
      "analyticsIdentifier": null,
      "gameDescription": "test",
      "genre": ""
    },
    {
      "creatorId": 209596022,
      "creatorType": "User",
      "totalUpVotes": 13,
      "totalDownVotes": 2,
      "universeId": 2043766328,
      "name": "Char les C3lvin Memorial",
      "placeId": 5763830729,
      "playerCount": 0,
      "price": null,
      "analyticsIdentifier": null,
      "gameDescription": "tedst",
      "genre": ""
    }
  ],
  "suggestedKeyword": null,
  "correctedKeyword": null,
  "filteredKeyword": null,
  "hasMoreRows": true,
  "nextPageExclusiveStartId": null,
  "featuredSearchUniverseId": null,
  "emphasis": false,
  "cutOffIndex": null,
  "algorithm": "GameSearchUsingSimilarQueryService",
  "algorithmQueryType": "Bucketboost",
  "suggestionAlgorithm": "GameSuggestions_V2",
  "relatedGames": [],
  "esDebugInfo": null
}
6
  • Create a class structure which matches this structure and deserialize the JSON string to an instance of that class. Then you can use/manipulate the data on that object as needed. Commented Jun 1, 2022 at 15:34
  • json2csharp.com Commented Jun 1, 2022 at 15:35
  • Sorry i'm new in Newtonsoft.JSON how do I do that? Commented Jun 1, 2022 at 15:36
  • stackoverflow.com/questions/34103498/… Commented Jun 1, 2022 at 15:43
  • I'm trying to parse multiple like 100 rows as I am scraping these. Commented Jun 1, 2022 at 15:48

1 Answer 1

1

there are a lot of ways to get data from json. It depends what do you need. For example you can learn this

    List<Game> games = JObject.Parse(json)["games"].ToObject<List<Game>>();

how to use

    Game game = games.Where(g => g.name == "Char les C3lvin Memorial").FirstOrDefault();

Game class

public class Game
{
    public int creatorId { get; set; }
    public string creatorType { get; set; }
    public int totalUpVotes { get; set; }
    public int totalDownVotes { get; set; }
    public int universeId { get; set; }
    public string name { get; set; }
    public object placeId { get; set; }
    public int playerCount { get; set; }
    public object price { get; set; }
    public object analyticsIdentifier { get; set; }
    public string gameDescription { get; set; }
    public string genre { get; set; }
}
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.