I have a json with structure like this:
{
"result":
[
{"a":{"b":1,"c":2}},
{"a":{"b":1,"c":2}},
{"a":{"b":1,"c":2}},
{"a":[]}
]
}
So I created class structure to parse this into C# objects:
public class JsonTest
{
public JsonTestResult[] result;
}
public class JsonTestResult
{
public JsonTestResultValue a;
}
public class JsonTestResultValue
{
public int b;
public int c;
}
when trying to parse this via LitJson
I get an error:
Type JsonTestResultValue can't act as an array
the problem is in this part of the json: {"a":[]}
, there must be {}
instead of []
, because it's really an object, not an array.
Now I'm stuck here and can't understand which type that I must use for this json property - array or any object type is unsuitable. All that I have on my mind now is to replace braces (with Regex of simple String.Replace
), but I'm sure, there must be more adequate way to deserialize this.