Dear Unity,
I have a rest call which implements sensor data and creates an object from it. For some reason it won’t parse my json into an object with JsonUtility.FromJson even though i have a valid json:
The error is:
system.ArgumentException' in UnityEngineProxy.dll
ArgumentException: JSON must represent an object type.
Which of course means that it must but a correct object type but as far as i can see it is correct.
My json which i recieve with www.downloadHandler.text would be:
"{\"guid\":\"2a005e1e-a417-43d9-812c-4cbec6e70847\",\"deviceName\":\"Bmp280Sensor\",\"level\":\"critical\"}"
with the object :
[System.Serializable]
public class Bmp280 {
public Guid guid;
public string deviceName;
public string level;
}
and it’s being called like this:
private Bmp280 TextToJsonBMP280Object(string getMessage)
{
System.Diagnostics.Debug.WriteLine("The message is: " + getMessage);
return JsonUtility.FromJson<Bmp280>(getMessage);
}
Does anyone see what I am doing wrong? As far as i can see it’s exactly what is requested from the function…