JsonUtility not working

Hello, i use this code:

string input = @"{""first"": ""Foo"", ""last"": ""Bar""}";
var res = JsonUtility.FromJson<Dictionary<string, object>> (input)

But variable “res” is empty dictionary. What i do wrong ?
The same situation i have when i use this code:

Dictionary<string, object> tmpDict1 = new Dictionary<string, object> ();
tmpDict1.Add("first", "Foo");

Dictionary<string, object> tmpDict2 = new Dictionary<string, object> ();
tmpDict2.Add("second", "Joe");

List<Dictionary<string, object>> lst = new List<Dictionary<string, object>> ();
lst.Add (tmpDict1);
lst.Add (tmpDict2);

var res = JsonUtility.ToJson(lst);

The variable “res” is empty string like “{}”.
What is it ? Why is it ?

Simply put, Unity does not support serialization and deserialization of dictionaries. As it is, JsonUtility is useless unless you want straight class serialization/deserialization from/to models that already exist.

If your data is in a dictionary, you can serialize it if you convert to arrays of keys and values first. But then the JSON won’t be following the same schema.

I hope they’ll support actual Dictionaries soon. You may want to watch this thread or vote for this request.