JsonUtility.FromJson cannot convert object from rest call

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:


with the object :

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…

I think it has something to do with the backslash before every quotation mark, or is this formatting because of this forum?

The JsonUtility makes JSON that looks like this:


So no backslashes :slight_smile:
Hope this was your problem,