[Unity][JSON] Unexpected node type (无法读取JSONObject与JSONArray数据)
发布时间
阅读量:
阅读量
在将string字符串变量转换为JSON数据格式的过程中,系统提示存在错误信息(Unexpected node type.)。
对应的JSON数据内容为
{"code":1}
AI写代码XML
...
[System.Serializable]
public class LoginJson
{
public int code = 0;
public int ccc = 0;
}
...
AI写代码cs
提取单一JSON数据的变量
在将字符串转化为JSON数据的过程中,若仅涉及一个JSON数据实例,采用该方式进行处理时,不会引发诸如“Unexpected node type.”之类的错误。
...
LoginJson wrapper = JsonUtility.FromJson<LoginJson>(msg);//单个变量
Debug.Log(wrapper.code);//JSONObject读取数据方法
...
全部评论 (0)
还没有任何评论哟~
