【发布时间】:2020-07-17 13:52:38
【问题描述】:
我正在尝试使用 SimpleJSON 在 Unity 中解析 .json 文件,但解析返回 null。
我的解析器类:
[SerializeField]
private string phrasesFileJSON = "conversations.json";
private JSONNode data;
public void Init () {
string jsonFile = phrasesFileJSON.Replace (".json", "");
TextAsset jsonObj = Resources.Load<TextAsset> (jsonFile);
data = JSONNode.Parse (jsonObj.ToString ());
Debug.Log ("Data null? " + !data);
Debug.Log (jsonObj.ToString());
}
调试打印:
Data null? True
和
{
"0-0": {
"speech": "Hello! This is a test phrase.",
"keyword": "Mountain"
}
}
所以文件被正确读取,但 JSONNode 无法解析它。谁能帮帮我?
【问题讨论】: