Hello, I have been stuck on a bug for some time now and any help would be appreciated parsing json files is kind of new to me.
//Hello, I have been stuck on a bug for quite some time any help would be appreciated I have a Json file, and I need to get nested items from the Json file.
[
{
"name": "River",
"description": "Items By River",
"Items":
[
{
"element": "Water",
"color": "Blue"
},
{
"element": "earth",
"color": "Brown"
},
{
"element": "fire",
"color": "Orange"
},
{
"element": "air",
"color": "White"
}
]
So I parse the Json Data with Two classes
public class Items
{
public string element
public string color
}
public ItemList
{
public List<Items> items;
}
//Declare
public ItemList itemList = new ItemList();
my Parse function
itemList = JsonUtility.FromJson<ItemList>(json);
now when I do this Unity give me a LIST of items. and when I access the items by calling
itemList.items[0] it returns an object
and when I do
itemList.items[0].element
it gives me the first item in the list.
what I want is a List of the Item List
so when I call ItemList.items[0]
it gives me the full list of items not just the first one.
{
"element": "Water",
"color": "Blue"
},
{
"element": "earth",
"color": "Brown"
},
{
"element": "fire",
"color": "Orange"
},
{
"element": "air",
"color": "White"
}
}
assist me in creating a list of list of objects after I parse them from the json GDL Space - A Space for GDL code.