So I have the following data structure defined in my program:
Dictionary<string, Dictionary<List<string>, int>> myTopDict = new Dictionary<string, Dictionary<List<string>, int>>();
Dictionary<List<string>, int> myInnerDict = new Dictionary<List<string>, int>();
int myIntValue=1;
List<string> myListValue=new List<string>();
myListValue.Add("Example Text 1");
myListValue.Add("Example Text 2");
//Here I add to my inner dictionary
myInnerDict.Add(myListValue, myIntValue);
//And finally adding to top dictionary
myTopDict.Add("My Data Set", myInnerDict);
//Serialize here
string result = JsonConvert.SerializeObject(myTopDict);
When I serialize the data structure, I am getting Collection text in the string as shown below:
What am I doing wrong here? Why I am not able to see my data in the serialized result?
, int> myInnerDict` is a dictionary with **complex keys**. If this is not a typo and you instead meant `Dictionary>>`, then Json.NET does not serialize such dictionaries out of the box, so you will need to implement a custom `JsonConverter` or `TypeConverter`. For details see [Not ableTo Serialize Dictionary with Complex key using Json.net](https://stackoverflow.com/q/24504245/3744182). In fact that may be a duplicate. Does it answer your question?
– dbc Sep 05 '22 at 21:08