I am very new to Unity and C#. I am trying to load a JSON-string to Unity and everything works as expected, but when i want to load a 2D-Array it doesn't work at all.
I have either this...
{
"status": 0,
"email": "exmpl@u",
"questions": [
{
"A": "Faro",
"C": "Oporto",
"B": "Lisbon",
"D": "Coimbra",
"question": "Which is the capital of Portugal?",
"your_answer": "",
"points": 10,
"correct_answer": "B"
},
{
"A": "Seville",
"C": "Madrid",
"B": "Barcelona",
"D": "C\u00e1ceres",
"question": "Which is the capital of Spain?",
"your_answer": "",
"points": 15,
"correct_answer": "C"
},
{
"A": "Gigon",
"C": "Cannes",
"B": "Marselle",
"D": "Paris",
"question": "Which is the capital of France?",
"your_answer": "",
"points": 20,
"correct_answer": "D"
}
]
}
...or this string
{
"status": 0,
"email": "exmpl@u",
"questions": [
{
"A": "Marcelo Rebelo de Sousa",
"C": "M\u00e1rio Soares",
"B": "Anibal Cavaco Silva",
"D": "Jorge Sampaio",
"question": "Which is the president of Portugal?",
"your_answer": "",
"points": 10,
"correct_answer": "A"
},
{
"A": "Fran\u00e7ois Miterrand",
"C": "Jacques Chirac",
"B": "Emmanuel Macron",
"D": "Nicolas Sarkozy",
"question": "Which is the president of France?",
"your_answer": "",
"points": 15,
"correct_answer": "B"
}
]
}
i created a class QuizData for saving all the objects in it, looking like this
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace QuizDataManager
{
public class QuizData
{
public int status;
public string email;
public string[] questions;
}
}
i can access the variables status and email easily myQuizDataObject.status or myQuizDataObject.email but i don't get anything with myQuizDataObject.questions[0] or something similar.
How do i do that?