using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Collections.ObjectModel;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
public class GenericDictionary<TKey, TValue> : Dictionary<TKey, TValue>
public GenericDictionary<string, double> currentResources = new GenericDictionary<string, double>();
currentResources.Add("EXP", 0);
currentResources.Add("Credits", 0);
public GenericDictionary<string, double> currentResources = new GenericDictionary<string, double>();
currentResources.Add("EXP", 0);
currentResources.Add("Credits", 0);
currentResources.Add("Apples", 0);
public static void Test()
v1.currentResources["Credits"] = 101.1;
var json1 = JsonConvert.SerializeObject(v1);
Console.WriteLine("Old JSON:");
Console.WriteLine(json1);
var v2 = JsonConvert.DeserializeObject<V2.Data>(json1);
Console.WriteLine("\nDeserialized {0}:", v2);
Console.WriteLine(JsonConvert.SerializeObject(v2));
v2.currentResources.Dump();
Assert.That(v2.currentResources.ContainsKey("Apples"));
Assert.That(new V2.Data().currentResources.Keys.All(k => v2.currentResources.ContainsKey(k)));
public static void Main()
Console.WriteLine("Environment version: {0} ({1})", System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription , Environment.Version);
Console.WriteLine("{0} version: {1}", typeof(JsonSerializer).Assembly.GetName().Name, typeof(JsonSerializer).Assembly.FullName);
Console.WriteLine("Failed with unhandled exception: ");