Unity WebGL JSON Failing?

Viewed 61

I have a Unity 2019 WebGL project in which I am calling a REST service to return a JSON string.

When I call for the data in the editor it is returned and deserialized perfectly into a class however when I compile to WebGL the same data fails.

My JSON string is: "{"status":"success","num":29,"id":"qsmKUMuia"}"

My class is:

[Serializable]
public class JSONClass
{
    public string status;
    public int num;
    public string id;

    public JSONClass()
    {

    }

    public JSONClass(string status, int num, string id)
    {
        this.status = status;
        this.num = num;
        this.id = id;
    }
}

I am simply trying:

JSONClass jsonClass = JsonConvert.DeserializeObject<JSONClass>(data);

The error it is giving is:

Error converting value "{"status":"success","num":29,"id":"qsmKUMuia"}" to type 'JSONClass'. Path '', line 1, position 58.

What mistake am I making here? I have also tried it with JsonUtility.FromJSON but that fails as well in WebGL.

0 Answers
Related