0

I'm using Refit in a project and i am trying to deserialize a json file which is not 'normalized' so to speak.

Here is the link to view an example, you can use ids 1491710 or 254700. Json Example from Steam

The problem is that the object that is in the root, always changes according to the id that you send in the request, thus making the json unpradonized, like:

{
    "dynamic property": {
       "success": true,
       "data": {
        //i want the data here
       }
}}

To be honest, I was able to do this, using a regular http request and going down to the json level to get the data object. example:

var jsonData = JToken.Parse(httpResult).First.First;
return jsonData["data"].ToObject<SteamAppResponse>();

But the problem here is that it is necessary to use the Refit library to maintain the design pattern.

My Refit interface:

public interface IStoreApiWebClient
{
    [Get("/appdetails?appids={appId}")]
    Task<SteamStoreAppResponse> GetAppDetails([Query][AliasAs("appId")] string appId);
}

My Response object:

public class SteamStoreAppResponse
{
    [JsonProperty("success")]
    public string Success { get; set; }

    [JsonProperty("data")]
    public SteamApp Data { get; set; }
}
Bazz
  • 35
  • 1
  • 9

0 Answers0