So i got an Json File like:
{
"name": "Project 1",
"views": [
{ "href": "YourURL" }
]
}
My own classes looks like this
[System.Serializable]
public class JsonClass {
public string name;
public views[] views;
public JsonClass(string jsonString) {
name = jsonString;
}
public JsonClass() { }
}
[System.Serializable]
public class views
{
public string href;
}
I load the json file with following which i found in the forum aswell:
public class JsonHandler : MonoBehaviour {
[RuntimeInitializeOnLoadMethod]
IEnumerator Start()
{
string url = "anotherURL";
WWW www = new WWW(url);
yield return www;
if (www.error != null)
{
Debug.Log("ERROR: " + www.error);
}
else
{
Debug.Log("No Error");
Debug.Log(www.text);
Debug.Log(ProcessJson(www.text));
}
}
private string ProcessJson(string jsonString) {
JsonClass parsejson = new JsonClass();
parsejson = JsonUtility.FromJson<JsonClass>(jsonString);
return parsejson.name;
}
The name is overwritten right but the views are empty. How can i handle this? I already searched in the Forum but didn´t found a working solution.