I am using Unity to make a game and I want to parse a JSON formatted string. I am using JsonUtility. The problem is that it doesn’t print anything. Here is my code:
string text = "{"italian": {"a": 1, "b": 2}, "english": {"a": 3, "b": 4}}";
Dictionary<string, Dictionary<string, string>> data = JsonUtility.FromJson<Dictionary<string, Dictionary<string, string>>>(text);
foreach (KeyValuePair<string, Dictionary<string, string>> languageEntry in data)
{
Debug.Log("Language: " + languageEntry.Key);
foreach (KeyValuePair<string, string> entry in languageEntry.Value)
{
Debug.Log(entry.Key + ": " + entry.Value);
}
}
My JSON object has 2 nested levels.