Pertinent sections of the class I'm trying to serialize/deserialize:
public class SampleClass
{
[JsonPropertyName("DimensionValueDictionary")]
public Dictionary<string, List<string>> DimensionValueDictionary { get; set; }
[JsonPropertyName("DimensionValueContentMappings")]
public Dictionary<HashSet<string>, string> DimensionValueMappings { get; set; }
public override string ToString()
{
return Newtonsoft.Json.JsonConvert.SerializeObject(this);
}
}
I'm able to successfully serialize and deserialize the first dictionary (with string as key), but I'm not able to figure out how to get the dictionary with hashset as key to serialize correctly.
var serializedSampleClass = sampleClassInstance.ToString();
var deSerializedSampleClassInstance = JsonConvert.DeserializeObject<SampleClass>(serializedSampleClass);
have no ideaknow what you are doing. – Alexei Levenkov May 25 '21 at 21:18