Home Game Development c# – UPDATED: Deserialise Nested JSON with JSON Utility Unity 5.4

c# – UPDATED: Deserialise Nested JSON with JSON Utility Unity 5.4

0
c# – UPDATED: Deserialise Nested JSON with JSON Utility Unity 5.4

[ad_1]

Your JSON firstly is defective and secondly doesn’t match the info mannequin.
To break down your JSON:

{
    "collection": [
        {,
            "points":[
                {
                    "ts": "1473850836254",
                    "value": "11.27"
                },
                {
                    "ts": "1473851256637",
                    "value": "6.44"
                }
            ]
        }
    ]
}

Do you see the issues?

  1. There is a , proper after the primary { bracket in collection.
  2. collection is an array and never an object like in your C# object mannequin.

To repair these errors and make your JSON appropriate with the C# object mannequin, take away the [] brackets for collection and the main comma:

{
    "collection": {
        "factors":[
            {
                "ts": "1473850836254",
                "value": "11.27"
            },
            {
                "ts": "1473851256637",
                "value": "6.44"
            }
        ]
    }
}

Also, change your knowledge kind of worth within the factors class to double, in any other case your values will not parse or can be truncated (I do not know the way JSON Utility handles this). Your JSON ought to be legitimate and parse with out errors.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here