using System;
using Newtonsoft.Json;

namespace InsurgenceData
{
    public static class Deserializer
    {
        private static readonly JsonSerializerSettings _settings = new JsonSerializerSettings()
        {
            NullValueHandling = NullValueHandling.Ignore,
            MissingMemberHandling = MissingMemberHandling.Ignore,
            Error = (sender, args) =>
            {
                Console.Error.WriteLine("Error in json: " + args.ErrorContext.Error.Message);
                args.ErrorContext.Handled = true;
            }
        };

        public static GamePokemon DeserializePokemon(string s)
        {
            return JsonConvert.DeserializeObject<GamePokemon>(s, _settings);
        }
    }
}