I have to deal with the JSON response of UnityWebRequest. I tried different methods of the unity builtin JsonUtility class but failed to convert JSON string to C# object as it shows a null reference error when I try to access a property of the converted object of JSON.
First, I converted my JSON string to C# structure classes using this online website and then, added [Serializable] attribute to my class like below code
[Serializable]
public class Root
{
public int statusCode { get; set; }
public string message { get; set; }
public Auth auth { get; set; }
}
When I was trying to convert it using JsonUtility.FromJson, it failed. Although it didn't throw any exception during conversion but failed to convert it as I was unable to log any property of the object.
Debug.Log(root .statusCode);
0 Comments