這是我的樣本JSON:使用JsonUtility.FromJson反序列化JSON在Unity
{"data":[{"id":141,"layoutLabel":"Sameer","hasCustomProb":1},
{"id":214,"layoutLabel":"abc","hasCustomProb":0}],"status":200}
這是我做
[System.Serializable]
public class PlayerInfo
{
public string [] data;
public int status;
}
類這是我如何得到 「狀態」 從JSON:
PlayerInfo P = JsonUtility.FromJson<PlayerInfo>(json);
Debug.Log(P.status) //returns 200
有人可以幫助我,我可以得到並保存數據數組或可能會得到data.id和data.hasCustomProb?我是C#和團結的新手。
數據不字符串型。在您的示例JSON中,它是一個包含「id」,「layoutLabel」和「hasCustomProb」屬性的對象數組。 – Lithium