I am not sure how to accomplish this. I am getting some users from an www request like this:
Dictionary<string, string> headers = new Dictionary<string, string>();
headers.Add("Authorization", "Basic "+System.Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes("user*pass")));
WWW www = new WWW("https://somedomain.com:8000/users", null, headers);
yield return www;
Debug.Log(www.text);
The debug returns this:
[{"user_id":"ho896ty6","user_name":"Mikje Flanders","age":43},{"user_id":"ft357hj","user_name":"Anna Simpson","age":56}]
Now, I have an object like this:
public class userData
{
string user_id;
string user_name;
int age;
}
which i would like to get the data into, but not sure when the json is an array. I tried like this, but with no luck:
userData thisUser = JsonUtility.FromJson<userData>(www.text);
Hope someone can help me with this and thanks in advance :-)