我正在尝试从服务器获取的 Json 中获取整数值。我使用了 Unity 库中的 JsonUtility,它运行良好。突然间它不再解析了。所有返回值均为 Null。
//SAMPLE CODE
SpinResult res = JsonUtility.FromJson<SpinResult>(download.downloadHandler.text);
spinValue = res.result;
//spinValue is always 0. It was working fine
//CLASS
[System.Serializable]
public class SpinResult
{
public int result;
}
//JSON
{
"data": {
"type": "",
"id": "",
"attributes": {
"server_seed": "",
"client_seed": "",
"result": 31,
},
"next_spin": {
"hashed_server_seed": "",
"client_seed": ""
}
}
}
我只需要整数“RESULT”,在本例中它应该是 31,但实际输出始终为 0。我每次都会检查 Json,它工作得很好。
至尊宝的传说
相关分类