- Home /
i don't get the output. please help me. Debug.Log(itemlist.item.Count); this value is 0.then Debug.Log( itemlist.item[i].Question) value not displayer.
[Serializable] public class Items { public int ID; public string Question; } [Serializable] public class ItemList { public List items; }
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class jsonload : MonoBehaviour { // Start is called before the first frame update void Start() { TextAsset asset = Resources.Load("SaveData") as TextAsset; Debug.Log(asset); if (asset != null) { ItemList itemList = JsonUtility.FromJson(asset.text);
Debug.Log(itemList.items[1].ID);
foreach (Items item in itemList.items)
{
Debug.Log("hi");
Debug.Log(item.ID);
Debug.Log(item.Question);
}
for (int i = 0; i < itemList.items.Count; i++)
{
Debug.Log(itemList.items[i].ID);
}
}
else
{
Debug.Log("Asset is null");
}
}
// Update is called once per frame
void Update()
{
}
}
/////json Data/////////// {"Items":[{"ID":12,"Question":"pc"},{"ID":1,"Question":"jjjjj"},{"ID":21,"Question":"dees"},{"ID":433,"Question":"hgvhgv"},{"ID":776,"Question":"hgftyfy"}]}
Your answer
![](https://koobas.hobune.stream/wayback/20220612232701im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
using multiple monitors / video outputs? 5 Answers
Very low FPS, only build shows problems? 0 Answers
Unity Shader Stream Output Stage 0 Answers
How to output a variable in a GUI.box? 2 Answers
Vibrate Windows Phone 8.1 1 Answer