C # in json array
I have the following structure json
:
{
[{
"name": "2542",
"type": "FOLDER",
"size": 0,
"time": 0,
"items": [{
"name": "10-1432927746000.ksf",
"type": "FILE",
"size": 225,
"time": 1433019520,
"items": null,
"info": {
"seller": 10,
"count": 2
}
}],
"info": null
}]
}
how can i parse it using c #? I tried var results = JsonConvert.DeserializeObject<dynamic>(json)
, but the result is an error:
Invalid property identifier character: [. Path '', line 1, position 1.
source to share
In addition to @Stephen awswer, you can only use an internal array like in this sample .
[{
"name": "2542",
"type": "FOLDER",
"size": 0,
"time": 0,
"items": [{
"name": "10-1432927746000.ksf",
"type": "FILE",
"size": 225,
"time": 1433019520,
"items": null,
"info": {
"seller": 10,
"count": 2
}
}],
"info": null
}]
Anyway, the problem seems to be your original json realy. =)
source to share
The JSON posted is not lint , so I suspect this is the root of your problem.
However, this does:
{
"things":[{
"name": "2542",
"type": "FOLDER",
"size": 0,
"time": 0,
"items": [{
"name": "10-1432927746000.ksf",
"type": "FILE",
"size": 225,
"time": 1433019520,
"items": null,
"info": {
"seller": 10,
"count": 2
}
}],
"info": null
}]
}
Notice how the outermost array now has an identifier that is required ; that is, your parsed object will have a property things
that is an array of this internal structure.
source to share