gpt4 book ai didi

C#解析json中的数组

转载 作者:行者123 更新时间:2023-11-30 14:28:01 24 4
gpt4 key购买 nike

我关注 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
}]
}

我如何用 C# 解析它?我试过var results = JsonConvert.DeserializeObject<dynamic>(json)但结果是错误的:

Invalid property identifier character: [. Path '', line 1, position 1.

最佳答案

作为@Stephen awswer 的补充,您还可以仅使用内部数组,如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
}]

无论如何,问题似乎真的出在您的原始 json 上。 =)

关于C#解析json中的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30557287/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com