Hi - I'm trying to deserialize an empty JSON array, and I'm getting an ArgumentException: JSON must represent an object type. I have tried both a simple wrapper class, e.g. Code (CSharp): string empty = "[]"; FriendManager.FriendList test = JsonUtility.FromJson<FriendManager.FriendList>(empty); Assert.IsNotNull(test); and also a regular List, e.g. Code (CSharp): string empty = "[]"; FriendManager.FriendList test = JsonUtility.FromJson<List<Friend>>(empty); Assert.IsNotNull(test); ...and either way when I try to deserialize the string "[]" via JsonUtility.FromJson I get the exception. Am I missing something obvious, or is this expected behavior?
Unity's Json serializer is pretty limited and my recollection is that it can't cope with naked arrays. You can have an object that contains an array, but the top-level construct in the original JSON needs to be an object. Code (CSharp): string exampleJson = "{ \"myArray\": [] }"