Unity3D JSON反序列化空列表? [英] Unity3D JSON Deserializing Empty List?
本文介绍了Unity3D JSON反序列化空列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个返回空列表(只是[]
)的Web服务.
I have a web service that returns an empty list (just []
).
JsonUtility.FromJson
给我一个
ArgumentException:JSON必须表示一个对象类型.
ArgumentException: JSON must represent an object type.
我已将其隔离为一些简单的代码,例如:
I have isolated this down to a bit of code as simple as:
string empty = "[]";
FriendManager.FriendList test = JsonUtility.FromJson<FriendManager.FriendList>(empty);
Assert.IsNotNull(test);
FriendList
只是Friend[]
的包装.我也尝试过List<Friend>
:
FriendList
is just a wrapper for Friend[]
. I also tried List<Friend>
:
string empty = "[]";
FriendManager.FriendList test = JsonUtility.FromJson<List<Friend>>(empty);
Assert.IsNotNull(test);
我缺少明显的东西吗?
我可以控制服务器数据(Spring Boot JSON Web服务)和客户端(Unity3D).
I have control over the server data (Spring Boot JSON web service) and the client (Unity3D).
推荐答案
查看全文