A list of a list

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.

Hi!

Forgive me if I’m not understanding the prompt correctly, but if you want a list of all the items isn’t that just itemList.items?

If you want, say, a list of just the colors instead of the color-element pair, you can use LINQ.Select() to extract whatever info you want:

List<string> colorList = itemList.items.Select(item => item.color).ToList();

Alternatively you could just restructure your class if you always want it this way:

public class Items
{        
      public List<string> elements;
      public List<string> colors;   
}

var items = JsonUtility.FromJson<Items>(json);
Debug.Log(items.colors[0]); //e.g. Blue