Trying to create a nested list in c# that can get data from the json file in unity It currently giving me this error
error CS1061: 'List<GameHandler.MyCard>' does not contain a definition for 'decision' and no accessible extension method 'decision' accepting a first argument of type 'List<GameHandler.MyCard>' could be found
I wanted to access that outcome1 array that inside the MyDecision list, but I can only access it up to
void Start()
{
CardData cardData = new CardData();
cardData.card.decision.outcome1 = new int[] { 1, 2, 3 };
}
[Serializable]
private class CardData
{
public List<MyCard> card;
}
[Serializable]
private class MyCard
{
public string[] speech;
public List<MyDecision> decision;
}
[Serializable]
private class MyDecision
{
public int[] outcome1;
public int[] outcome2;
}
Here is content of my JSON file that I want to access
{
"CardData" : [
{ "Speech" : ["Hi World."],
"Decision":[
{
"Outcome1":[1,0,0],
"Outcome2":[0,1,0]
}
]
},{
"Speech": ["Hello","World"],
"Decision":[
{
"Outcome1":[1,1,0],
"Outcome2":[0,1,1]
}
]
}
]
}