Reputation: 649
Struggling to find a good solution to parse this data or similar structure in Unity using C#:
{
"levels":{
"level1":{
{0,1,0,0},
{0,0,1,0},
{0,2,0,0},
{0,0,0,0},
}
}
}
I've tried the built in Unity C# class JsonUtility and Boomlagoon plugin but havent been able to parse the data into a Levels 2 dimensional array of different Levels.
Any help would be appreicated.
Upvotes: 0
Views: 102
Reputation: 10701
You won't find any solution as this is not a valid json.
The following would be a more appropriate solution:
{
"levels": [{
"name": "level1",
"data": [
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 2, 0, 0],
[0, 0, 0, 0]
]
}]
}
and the Csharp side would turn out to be :
public class Level
{
public string name;
public int[][]data;
}
public class RootObject
{
public Level[] levels;
}
Upvotes: 3