I have a dictionary like this:
var dict1 = new Dictionary<(int, int), int);
dict1.add((1,2), 3);
That is serialized to a string using:
var s = JsonConvert.SerializeObject(dict1);
// s = "{\"(1,2)\":\"3\"}";
When trying to deserialize the string using:
var j = JsonConvert.DeserializeObject<Dictionary<(int, int), int>>(s);
I get an error like:
'Could not convert string '(1,2)' to dictionary key type 'System.ValueTuple`2[System.Int32,System.Int32]'. Create a TypeConverter to convert from the string to the key type object.
How can I deserialize my string into a tuple key? Using a custom object or a TypeConverter
? If so, how?