First, use code tags:
Next.
JsonUtility only supports parsing json to an existing class structure. If you want to be able to loose parse it into a lookup table, or dictionary. Use something like Json.NET:
Json.NET - Newtonsoft
There are also more compact versions as well. Like this one on unify:
http://wiki.unity3d.com/index.php/SimpleJSON
…
If you want to use JsonUtility, like I said, you must create the class structure it would parse into.
First off… you json is malformed…
If “data” is supposed to be an array, and “answers” is supposed to be an array. You may also want to change those bool responses from 1/0 to true/false… json supports bools. It should look like this:
{
"success":true,
"errors":[],
"data":
[
{
"question_name":"First question",
"answers":
[
{"name":"120","correct":false},
{"name":"90","correct":false},
{"name":"85","correct":false},
{"name":"110","correct":true}
]
},
{
"question_name":"Second question",
"answers":
[
{"name":"Big","correct":false},
{"name":"Small","correct":false},
{"name":"Thin","correct":false},
{"name":"Thick","correct":true}
]
}
]
}
And you might shape your class structure like this:
[System.Serializable]
public class Response
{
public bool success;
public ?[] errors; //your example json doesn't give a description of what might appear here
public QuestionData[] data;
}
[System.Serializable]
public class QuestionData
{
public string question_name;
public AnswerData[] answers;
}
[System.Serializable]
public class AnswerData
{
public string name;
public bool correct;
}