0

I'm trying to get the nodes inside a JSON request, this: https://store.steampowered.com/api/appdetails?appids=731490

But it's returning a format that a online json convert doesn't recognize and i can't get the values of nodes with C#.

Currently, i'm trying:

var gameInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<object>(response.Content.ReadAsStringAsync().Result);
JObject jObject = JObject.Parse(gameInfo.ToString());
string header = (string)jObject.SelectToken("header_image");

But it return null for all properties. How do i access the header_image that is inside json object?

EDIT: JSON SAMPLE

{"731490":{"success":true,"data":{"type":"game","name":"Crash Bandicoot\u2122 N. Sane Trilogy","steam_appid":731490,"required_age":0,"is_free":false,"detailed_description":"Seu marsupial favorito, Crash Bandicoot\u2122, est\u00e1 de volta! Ele est\u00e1 aprimorado, inspirado e preparado para dan\u00e7ar na cole\u00e7\u00e3o de jogos da trilogia insana. Agora voc\u00ea pode jogar Crash Bandicoot como nunca antes. Gire, pule, golpeie e repita conforme voc\u00ea enfrentar as aventuras e os desafios \u00e9picos atrav\u00e9s dos tr\u00eas jogos que deram in\u00edcio a tudo, Crash Bandicoot\u2122, Crash Bandicoot\u2122 2: Cortex Strikes Back e Crash Bandicoot\u2122: Warped. Reviva todos os seus momentos favoritos de Crash em seu apogeu gr\u00e1fico em HD totalmente remasterizado e se prepare para colocar um CRASH nos seus golpes!<h2 class=\"bb_tag\">Crash Bandicoot\u2122 N. Sane Trilogy Stormy Ascent<\/h2><br>Vivencie a not\u00f3ria Stormy Ascent do jogo Crash Bandicoot original. Antes incompleta e nunca lan\u00e7ada, essa fase vai desafiar at\u00e9 os f\u00e3s mais veteranos do Crash! Ser\u00e1 que voc\u00ea consegue enfrentar degraus que se retraem, assistentes atiradores de frascos, p\u00e1ssaros ferozes, plataformas m\u00f3veis e espinhos de ferro? Baixe e jogue a fase Stormy Ascent!<h2 class=\"bb_tag\">Crash Bandicoot N. Sane Trilogy Future Tense<\/h2><br>Jogue a primeira fase NOVA para a trilogia original em quase 20 anos. Inspirado na fase &quot;Waterfall&quot; do primeiro jogo de Crash Bandicoot, Future Tense apresenta v\u00e1rios quebra-cabe\u00e7as da fase original ambientados em um cen\u00e1rio futurista de Crash Bandicoot 3: Warped. Descubra um novo n\u00edvel de dificuldade para Crash Bandicoot N. Sane Trilogy desviando de foguetes, destruindo rob\u00f4s e pulando lasers enquanto voc\u00ea sobe por um arranha-c\u00e9u enorme e futurista.","about_the_game":"Seu marsupial favorito, Crash Bandicoot\u2122, est\u00e1 de volta! Ele est\u00e1 aprimorado, inspirado e preparado para dan\u00e7ar na cole\u00e7\u00e3o de jogos da trilogia insana. Agora voc\u00ea pode jogar Crash Bandicoot como nunca antes. Gire, pule, golpeie e repita conforme voc\u00ea enfrentar as aventuras e os desafios \u00e9picos atrav\u00e9s dos tr\u00eas jogos que deram in\u00edcio a tudo, Crash Bandicoot\u2122, Crash Bandicoot\u2122 2: Cortex Strikes Back e Crash Bandicoot\u2122: Warped. Reviva todos os seus momentos favoritos de Crash em seu apogeu gr\u00e1fico em HD totalmente remasterizado e se prepare para colocar um CRASH nos seus golpes!<h2 class=\"bb_tag\">Crash Bandicoot\u2122 N. Sane Trilogy Stormy Ascent<\/h2><br>Vivencie a not\u00f3ria Stormy Ascent do jogo Crash Bandicoot original. Antes incompleta e nunca lan\u00e7ada, essa fase vai desafiar at\u00e9 os f\u00e3s mais veteranos do Crash! Ser\u00e1 que voc\u00ea consegue enfrentar degraus que se retraem, assistentes atiradores de frascos, p\u00e1ssaros ferozes, plataformas m\u00f3veis e espinhos de ferro? Baixe e jogue a fase Stormy Ascent!<h2 class=\"bb_tag\">Crash Bandicoot N. Sane Trilogy Future Tense<\/h2><br>Jogue a primeira fase NOVA para a trilogia original em quase 20 anos. Inspirado na fase &quot;Waterfall&quot; do primeiro jogo de Crash Bandicoot, Future Tense apresenta v\u00e1rios quebra-cabe\u00e7as da fase original ambientados em um cen\u00e1rio futurista de Crash Bandicoot 3: Warped. Descubra um novo n\u00edvel de dificuldade para Crash Bandicoot N. Sane Trilogy desviando de foguetes, destruindo rob\u00f4s e pulando lasers enquanto voc\u00ea sobe por um arranha-c\u00e9u enorme e futurista.","short_description":"Seu marsupial favorito, Crash Bandicoot\u00ae, voltou! Aprimorado, inspirado e pronto para dan\u00e7ar nessa trilogia insana. Reviva seus momentos favoritos em Crash Bandicoot\u2122, Crash Bandicoot\u2122 2: Cortex Strikes Back e Crash Bandicoot\u2122 3: Warped, agora com gr\u00e1ficos HD completamente remasterizados!","supported_languages":"Ingl\u00eas<strong>*<\/strong>, Franc\u00eas<strong>*<\/strong>, Italiano<strong>*<\/strong>, Alem\u00e3o<strong>*<\/strong>, Espanhol (Espanha)<strong>*<\/strong><br><strong>*<\/strong>idiomas com suporte total de \u00e1udio","header_image":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/header.jpg?t=1568841571","website":"https:\/\/www.crashbandicoot.com","pc_requirements":{"minimum":"<strong>M\u00ednimos:<\/strong><br><ul class=\"bb_ul\"><li><strong>SO:<\/strong> Windows 7<br><\/li><li><strong>Processador:<\/strong> Intel Core i5-750 @ 2.67GHz | AMD Phenom II X4 965 @ 3.4GHz<br><\/li><li><strong>Mem\u00f3ria:<\/strong> 8 GB de RAM<br><\/li><li><strong>Placa de v\u00eddeo:<\/strong> NVIDIA GeForce GTX 660 2GB | AMD Radeon HD 7850 2GB<br><\/li><li><strong>DirectX:<\/strong> Vers\u00e3o 9.0c<br><\/li><li><strong>Armazenamento:<\/strong> 30 GB de espa\u00e7o dispon\u00edvel<br><\/li><li><strong>Placa de som:<\/strong> DirectX 9.0c Compatible<\/li><\/ul>"},"mac_requirements":[],"linux_requirements":[],"legal_notice":"\u00a9 2018 Activision Publishing, Inc. ACTIVISION e CRASH BANDICOOT s\u00e3o marcas comerciais da Activision Publishing, Inc.","developers":["Vicarious Visions","Iron Galaxy"],"publishers":["Activision"],"price_overview":{"currency":"BRL","initial":15000,"final":15000,"discount_percent":0,"initial_formatted":"","final_formatted":"R$ 150,00"},"packages":[213423],"package_groups":[{"name":"default","title":"Comprar Crash Bandicoot\u2122 N. Sane Trilogy","description":"","selection_text":"Selecione uma op\u00e7\u00e3o de compra","save_text":"","display_type":0,"is_recurring_subscription":"false","subs":[{"packageid":213423,"percent_savings_text":"","percent_savings":0,"option_text":"Crash Bandicoot\u2122 N. Sane Trilogy - R$ 150,00","option_description":"","can_get_free_license":"0","is_free_license":false,"price_in_cents_with_discount":15000}]}],"platforms":{"windows":true,"mac":false,"linux":false},"categories":[{"id":2,"description":"Um jogador"},{"id":22,"description":"Conquistas Steam"},{"id":29,"description":"Cartas Colecion\u00e1veis Steam"},{"id":18,"description":"Compatibilidade parcial com controle"},{"id":23,"description":"Nuvem Steam"},{"id":41,"description":"Remote Play no celular"},{"id":42,"description":"Remote Play no tablet"}],"genres":[{"id":"1","description":"A\u00e7\u00e3o"}],"screenshots":[{"id":0,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_66d4bf28161b1c7a5a78f579bcea05a0785f2c50.600x338.jpg?t=1568841571","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_66d4bf28161b1c7a5a78f579bcea05a0785f2c50.1920x1080.jpg?t=1568841571"},{"id":1,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_931f13ad19753ac5d491bc55e31ec9e2181ca637.600x338.jpg?t=1568841571","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_931f13ad19753ac5d491bc55e31ec9e2181ca637.1920x1080.jpg?t=1568841571"},{"id":2,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_312f4dbd137af1b36c3572aaa79349db6dd841a2.600x338.jpg?t=1568841571","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_312f4dbd137af1b36c3572aaa79349db6dd841a2.1920x1080.jpg?t=1568841571"},{"id":3,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_76889923300ce3a20d7a57b3b42d9f4d549106f3.600x338.jpg?t=1568841571","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_76889923300ce3a20d7a57b3b42d9f4d549106f3.1920x1080.jpg?t=1568841571"},{"id":4,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_73fcdfb2150a35d1bbe824581555d39f57c31234.600x338.jpg?t=1568841571","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_73fcdfb2150a35d1bbe824581555d39f57c31234.1920x1080.jpg?t=1568841571"},{"id":5,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_c2439741a40a81e4772412b4a92866aa1f188f2f.600x338.jpg?t=1568841571","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_c2439741a40a81e4772412b4a92866aa1f188f2f.1920x1080.jpg?t=1568841571"},{"id":6,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_ec680b2e1d6314aeab89627fe7e3118f6b884026.600x338.jpg?t=1568841571","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_ec680b2e1d6314aeab89627fe7e3118f6b884026.1920x1080.jpg?t=1568841571"},{"id":7,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_6df148c304cc75e3e6a064f74897b098b93e7999.600x338.jpg?t=1568841571","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_6df148c304cc75e3e6a064f74897b098b93e7999.1920x1080.jpg?t=1568841571"},{"id":8,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_106c1ce7c8fbfec289d9005385209c592cd8a03e.600x338.jpg?t=1568841571","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_106c1ce7c8fbfec289d9005385209c592cd8a03e.1920x1080.jpg?t=1568841571"},{"id":9,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_fad459eb04408dd926de3b789c8bc6d13bf855c0.600x338.jpg?t=1568841571","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_fad459eb04408dd926de3b789c8bc6d13bf855c0.1920x1080.jpg?t=1568841571"},{"id":10,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_d02c73a64ac53da19d336c64821e6e66f94aa912.600x338.jpg?t=1568841571","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_d02c73a64ac53da19d336c64821e6e66f94aa912.1920x1080.jpg?t=1568841571"},{"id":11,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_5570ddf9fd565900d83b5a89099f6eecc07780cd.600x338.jpg?t=1568841571","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_5570ddf9fd565900d83b5a89099f6eecc07780cd.1920x1080.jpg?t=1568841571"},{"id":12,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_1a5bd0956c774afcadb1474f5fed2085715f2987.600x338.jpg?t=1568841571","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_1a5bd0956c774afcadb1474f5fed2085715f2987.1920x1080.jpg?t=1568841571"},{"id":13,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_52a34a9b5105ae4bd77f4a15e735282f000dd239.600x338.jpg?t=1568841571","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_52a34a9b5105ae4bd77f4a15e735282f000dd239.1920x1080.jpg?t=1568841571"},{"id":14,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_c65647d67a01dd01ba99fbfd9a46bc5220a8c5cf.600x338.jpg?t=1568841571","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_c65647d67a01dd01ba99fbfd9a46bc5220a8c5cf.1920x1080.jpg?t=1568841571"},{"id":15,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_bf301672eede469605ef823057cba1eb3b845f12.600x338.jpg?t=1568841571","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_bf301672eede469605ef823057cba1eb3b845f12.1920x1080.jpg?t=1568841571"},{"id":16,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_1658e70049a0de5ec46606696719771c5c72842a.600x338.jpg?t=1568841571","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_1658e70049a0de5ec46606696719771c5c72842a.1920x1080.jpg?t=1568841571"},{"id":17,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_54e91fcc8981a7464b7e58d9b7836c4735f03333.600x338.jpg?t=1568841571","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_54e91fcc8981a7464b7e58d9b7836c4735f03333.1920x1080.jpg?t=1568841571"},{"id":18,"path_thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_1fd131fc50ca8f4a849de5eec97260b88a5865c6.600x338.jpg?t=1568841571","path_full":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/ss_1fd131fc50ca8f4a849de5eec97260b88a5865c6.1920x1080.jpg?t=1568841571"}],"movies":[{"id":256720063,"name":"Crash Bandicoot\u2122 N. Sane Trilogy - Future Tense Launch Trailer","thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/256720063\/movie.293x165.jpg?t=1529112507","webm":{"480":"http:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/256720063\/movie480.webm?t=1529112507","max":"http:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/256720063\/movie_max.webm?t=1529112507"},"highlight":true},{"id":256711002,"name":"Crash Bandicoot\u2122 N. Sane Trilogy - Better With Crashitude Gameplay Trailer","thumbnail":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/256711002\/movie.293x165.jpg?t=1520629752","webm":{"480":"http:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/256711002\/movie480.webm?t=1520629752","max":"http:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/256711002\/movie_max.webm?t=1520629752"},"highlight":true}],"recommendations":{"total":4662},"achievements":{"total":74,"highlighted":[{"name":"C1 | Papu Popped","path":"https:\/\/steamcdn-a.akamaihd.net\/steamcommunity\/public\/images\/apps\/731490\/ebf5292157d9da9b5a32148986275a9d75e3c485.jpg"},{"name":"C1 | Ripper Ruined","path":"https:\/\/steamcdn-a.akamaihd.net\/steamcommunity\/public\/images\/apps\/731490\/29032c985b872eca1a55963e5b983f1468e1d992.jpg"},{"name":"C1 | Spin Doctor","path":"https:\/\/steamcdn-a.akamaihd.net\/steamcommunity\/public\/images\/apps\/731490\/cafabcaa86bd99c7ec49d00e86433eb128fbcd21.jpg"},{"name":"C1 | I Meant To Do That!","path":"https:\/\/steamcdn-a.akamaihd.net\/steamcommunity\/public\/images\/apps\/731490\/8e2ad82dafb8919bb05a8b878476daba9008c2fc.jpg"},{"name":"C1 | That's What Those Do!","path":"https:\/\/steamcdn-a.akamaihd.net\/steamcommunity\/public\/images\/apps\/731490\/14e3928a27da6ad10a0975b86ea911c2cb18aa1f.jpg"},{"name":"C1 | Catch Me If You Can!","path":"https:\/\/steamcdn-a.akamaihd.net\/steamcommunity\/public\/images\/apps\/731490\/25b9aade232f9ee39c071d03022793d8186e3842.jpg"},{"name":"C1 | Feeeed Meeeee!","path":"https:\/\/steamcdn-a.akamaihd.net\/steamcommunity\/public\/images\/apps\/731490\/c0d6ffe87c82274914211c6f393c5bb59417a066.jpg"},{"name":"C1 | The Box That Broke the Bandicoot's Back","path":"https:\/\/steamcdn-a.akamaihd.net\/steamcommunity\/public\/images\/apps\/731490\/f244e975d9dbe6610228ac6f4bbb07bf5a1b4752.jpg"},{"name":"C1 | Koala Konked","path":"https:\/\/steamcdn-a.akamaihd.net\/steamcommunity\/public\/images\/apps\/731490\/c4c275da3ca63c62d5e26f0947d5fc64e51f9ff1.jpg"},{"name":"C1 | Pinstripe Patooey","path":"https:\/\/steamcdn-a.akamaihd.net\/steamcommunity\/public\/images\/apps\/731490\/bd2cdeaad120e2b2b16f37f94e05db8b9acb83d5.jpg"}]},"release_date":{"coming_soon":false,"date":"29\/jun\/2018"},"support_info":{"url":"https:\/\/support.activision.com\/","email":""},"background":"https:\/\/steamcdn-a.akamaihd.net\/steam\/apps\/731490\/page_bg_generated_v6b.jpg?t=1568841571","content_descriptors":{"ids":[],"notes":null}}}}
8
  • Include the json sample in your post please. Commented Mar 2, 2020 at 20:44
  • Sample Included. Commented Mar 2, 2020 at 20:46
  • 1
    Well i went to jsonlint.com posted the output from your link and it shows as valid json... so i am not sure what you mean. Also your json seems to have HTML portions in it. so you might want to html decode the response after the fact. Commented Mar 2, 2020 at 20:52
  • 1
    I would recommend that you create an actual model. Commented Mar 2, 2020 at 20:54
  • @JonathanAlfaro try this json on json2csharp.com, it don't work properly. Commented Mar 2, 2020 at 21:06

3 Answers 3

1

Use a strongly typed model.

This is what I did.

  1. Tested the JSON at https://jsonlint.com/ to make sure it is valid.
  2. Used http://json2csharp.com/ to generate a strongly typed model.

I was able to read the entire contents of the JSON in this link: https://store.steampowered.com/api/appdetails?appids=731490

This is how made it work:

var result = JsonConvert.DeserializeObject<RootObject>(response.Content.ReadAsStringAsync().Result);

The model I used is this: Notice that the RootObject inherits from

Dictionary<string, AppRoot>

Notice also that the name of the "invalid" type is now AppRoot.

This will now support multiple Apps by ID

  public class RootObject: Dictionary<string, AppRoot>
  {

  }

  public class AppRoot
  {
    public bool success { get; set; }
    public Data data { get; set; }
  }

  public class PcRequirements
  {
    public string minimum { get; set; }
  }

  public class PriceOverview
  {
    public string currency { get; set; }
    public int initial { get; set; }
    public int final { get; set; }
    public int discount_percent { get; set; }
    public string initial_formatted { get; set; }
    public string final_formatted { get; set; }
  }

  public class Sub
  {
    public int packageid { get; set; }
    public string percent_savings_text { get; set; }
    public int percent_savings { get; set; }
    public string option_text { get; set; }
    public string option_description { get; set; }
    public string can_get_free_license { get; set; }
    public bool is_free_license { get; set; }
    public int price_in_cents_with_discount { get; set; }
  }

  public class PackageGroup
  {
    public string name { get; set; }
    public string title { get; set; }
    public string description { get; set; }
    public string selection_text { get; set; }
    public string save_text { get; set; }
    public int display_type { get; set; }
    public string is_recurring_subscription { get; set; }
    public List<Sub> subs { get; set; }
  }

  public class Platforms
  {
    public bool windows { get; set; }
    public bool mac { get; set; }
    public bool linux { get; set; }
  }

  public class Category
  {
    public int id { get; set; }
    public string description { get; set; }
  }

  public class Genre
  {
    public string id { get; set; }
    public string description { get; set; }
  }

  public class Screenshot
  {
    public int id { get; set; }
    public string path_thumbnail { get; set; }
    public string path_full { get; set; }
  }

  public class Webm
  {
    public string __invalid_name__480 { get; set; }
    public string max { get; set; }
  }

  public class Movie
  {
    public int id { get; set; }
    public string name { get; set; }
    public string thumbnail { get; set; }
    public Webm webm { get; set; }
    public bool highlight { get; set; }
  }

  public class Recommendations
  {
    public int total { get; set; }
  }

  public class Highlighted
  {
    public string name { get; set; }
    public string path { get; set; }
  }

  public class Achievements
  {
    public int total { get; set; }
    public List<Highlighted> highlighted { get; set; }
  }

  public class ReleaseDate
  {
    public bool coming_soon { get; set; }
    public string date { get; set; }
  }

  public class SupportInfo
  {
    public string url { get; set; }
    public string email { get; set; }
  }

  public class ContentDescriptors
  {
    public List<object> ids { get; set; }
    public object notes { get; set; }
  }

  public class Data
  {
    public string type { get; set; }
    public string name { get; set; }
    public int steam_appid { get; set; }
    public int required_age { get; set; }
    public bool is_free { get; set; }
    public string detailed_description { get; set; }
    public string about_the_game { get; set; }
    public string short_description { get; set; }
    public string supported_languages { get; set; }
    public string header_image { get; set; }
    public string website { get; set; }
    public PcRequirements pc_requirements { get; set; }
    public List<object> mac_requirements { get; set; }
    public List<object> linux_requirements { get; set; }
    public string legal_notice { get; set; }
    public List<string> developers { get; set; }
    public List<string> publishers { get; set; }
    public PriceOverview price_overview { get; set; }
    public List<int> packages { get; set; }
    public List<PackageGroup> package_groups { get; set; }
    public Platforms platforms { get; set; }
    public List<Category> categories { get; set; }
    public List<Genre> genres { get; set; }
    public List<Screenshot> screenshots { get; set; }
    public List<Movie> movies { get; set; }
    public Recommendations recommendations { get; set; }
    public Achievements achievements { get; set; }
    public ReleaseDate release_date { get; set; }
    public SupportInfo support_info { get; set; }
    public string background { get; set; }
    public ContentDescriptors content_descriptors { get; set; }
  }
Sign up to request clarification or add additional context in comments.

6 Comments

The RootObject class can instead be replaced by a Dictionary<string, Type__7314890>. That would allow the model to support any App ID.
@RJ yes i agree
Well @JonathanAlfaro this worked fine, but only for appID: 731490, if i try another, like 546560, then it don't works, is there a way to set this jsonproperty dinamically?
@Bazz yes sure.... I will change my answer to be dynamic. Please mark as answered if it works for you
It Worked. Thank you for your patience.
|
1

JObject.SelectToken expects a path to a particular token. It doesn't traverse the object to find anything with a matching name.

Looking at the object, the root object seems to have a single property with the key being the app id. That in turn has two properties, success and data, with data containing the actual info you seek.

The following works for me:

using var client = new HttpClient();
var text = await client.GetStringAsync("https://store.steampowered.com/api/appdetails?appids=731490");
var jo = JObject.Parse(text);
var header = (string)jo.SelectToken("731490.data.header_image");

Having a strongly typed model would make this easier in the long run, though.

3 Comments

How do i type if the number, 731490 is dynamic? i mean, the number is an app id, an if i send another app id, the number changes, so if i try to type this json on json2csharp.com it gives me a error
appId + ".data.header_image", or $"{appId}.data.header_image", or jo[appId].SelectToken("data.header_image"), or...
Thank you for your answer, it worked, but then i had another problem, but your answer worked, and thank you so much for replying.
1

I think you must await your method to reduce thread locks

var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

Then you could try this

var gameInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<JObject>(content);
string header = gameInfo["731490"]["data"]["header_image"];

To ignore first dynamic element:

gameInfo.Properties().Children().ToList()[0]["data"]["header_image"]

1 Comment

Your answer worked, but then i had another need, but your answer is correct. Thank you so much for replying my post.

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.