Hello!
I have a simple PHP script that is getting data from MySQL, making a two dimensional array from them and then encoding it to JSON.
$resultArray = array();
while($row = mysqli_fetch_array($result)){
$resultArray[] = array("id"=>$row['id'], "name"=>$row['name'], "description"=>$row['description'], "points"=>$row['points'], );
}
$resultJSON = json_encode($resultArray);
JSON looks like this:
[
{
"id":"9",
"name":"name",
"description":"",
"points":"12"
},
{
"id":"10",
"name":"Namename",
"description":"Description",
"points":"21"
},
{
"id":"12",
"name":"Namenamename",
"description":"p",
"points":"54"
}
]
Now I want to download the JSON string to Unity and convert it to two-dimensional array. This is my code so far:
IEnumerator getArray() {
string query = wwwURL;
WWW array_get = new WWW(query);
yield return array_get;
if(array_get.text != null){
JSON = array_get.text;
}
}
How to do it? Any example?
I was looking on the web, but I didn’t understand anything. Is any Unity JSON parser supporting there arrays?