<commit_before>﻿using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SteamWebAPI2.Models.SteamStore;
using System;
using System.Reflection;

namespace SteamWebAPI2.Utilities.JsonConverters
{
    /// <summary>
    /// Take some special steps when deserializing the AppDetails response since the response has a dynamic property based on the app id which is passed as a parameter.
    /// For example, passing app id "570" to the AppDetails endpoint will give a response like so:
    /// "570": {
    ///     "success": true
    /// }
    /// </summary>
    internal class StoreAppDetailsContainerJsonConverter : JsonConverter
    {
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            throw new NotImplementedException();
        }

        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (reader.TokenType == JsonToken.Null)
            {
                return null;
            }

            JObject o = JObject.Load(reader);

            foreach (var x in o)
            {
                var data = x.Value["data"].ToObject<Data>();
                return data;
            }

            return null;
        }

        public override bool CanWrite { get { return false; } }

        public override bool CanConvert(Type objectType)
        {
            return typeof(AppDetailsContainer).GetTypeInfo().IsAssignableFrom(objectType.GetTypeInfo());
        }
    }
}<commit_msg>Fixed StoreAppDetailsContainerJsonConverter to return the correct expected object in SteamStore.cs instead.<commit_after>﻿using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SteamWebAPI2.Models.SteamStore;
using System;
using System.Reflection;

namespace SteamWebAPI2.Utilities.JsonConverters
{
    /// <summary>
    /// Take some special steps when deserializing the AppDetails response since the response has a dynamic property based on the app id which is passed as a parameter.
    /// For example, passing app id "570" to the AppDetails endpoint will give a response like so:
    /// "570": {
    ///     "success": true
    /// }
    /// </summary>
    internal class StoreAppDetailsContainerJsonConverter : JsonConverter
    {
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            throw new NotImplementedException();
        }

        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (reader.TokenType == JsonToken.Null)
            {
                return null;
            }

            JObject o = JObject.Load(reader);

            foreach (var x in o)
            {
				// Edit by Jir : Previously returning Data; should return the correct object AppDetailsContainer instead. Sorry for ugly code
                var data = x.Value["data"].ToObject<Data>();
                var success = x.Value["success"].ToObject<bool>();
                AppDetailsContainer appDetailsContainer = new AppDetailsContainer{ Data = data, Success = success };
                return appDetailsContainer;
				
				// return data; 
            }

            return null;
        }

        public override bool CanWrite { get { return false; } }

        public override bool CanConvert(Type objectType)
        {
            return typeof(AppDetailsContainer).GetTypeInfo().IsAssignableFrom(objectType.GetTypeInfo());
        }
    }
}
{'fraction_non_alphanumeric': 0.0814773047645898, 'fraction_numerical': 0.004510854243022272, 'mean_word_length': 2.279112754158965, 'pattern_counts': {'":': 4, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7252673', 'n_tokens_mistral': 880, 'n_tokens_neox': 846, 'n_words': 282}