I am receiving a JSON string from an API and I need to deserialize it into something I can use in C# and Unity. I am trying to use Unity's JSON Serialization but it doesn't seem to be working for me?
Here is an example of the JSON structure from the API:
{
"results": [
[
"2016-09-01/20160901_200002_000.jpg",
"2016-09-01/20160901_192851_000.jpg",
"2016-09-01/20160901_193443_000.jpg",
"2016-09-01/20160901_210130_000.jpg"
],
[
"2016-09-02/20160902_104409_000.jpg",
"2016-09-01/20160901_165949_000.jpg"
],
[
"2016-09-02/20160902_104409_000.jpg",
"2016-09-02/20160902_104721_000.jpg",
"2016-09-02/20160902_093420_000.jpg",
],
[
"2016-09-02/20160902_082554_000.jpg"
]
]
}
This is my code trying to deserialize the JSON into a custom class using Unity's JsonUtility class:
[Serializable]
public class MyClass
{
public List<List<string>> results;
}
MyClass test = JsonUtility.FromJson<MyClass>(jsonString);
Debug.Log(test.results); // this is just returning null
Anyone any idea what I'm doing wrong?
EDIT: This answer seems to suggest it is because JsonUtility does not support arrays and provides a helper class but it isn't working for this issue.