c# - 反序列化嵌套在数组中的对象
问题描述
我正在努力反序列化从 API 接收的以下 JSON 字符串:
{
"appointment_types": [
{
"id": 279148,
"max_attendees": 1,
"name": "Follow up",
"billable_item": {
"links": {
"self": "https://api.cliniko.com/v1/billable_items/485545"
}
},
"practitioners": {
"links": {
"self": "https://api.cliniko.com/v1/appointment_types/279148/practitioners"
}
}
},
{
"id": 279149,
"max_attendees": 1,
"name": "Assessment",
"billable_item": {
"links": {
"self": "https://api.cliniko.com/v1/billable_items/490437"
}
},
"practitioners": {
"links": {
"self": "https://api.cliniko.com/v1/appointment_types/279149/practitioners"
}
}
}
],
"total_entries": 17,
"links": {
"self": "https://api.cliniko.com/v1/appointment_types?page=1"
}
}
我已经搜索过,但找不到任何适用于上述内容的内容。
任何可能使我走上正轨的指针将不胜感激。
解决方案
这对我来说似乎工作得很好,只是使用动态......
dynamic d = JObject.Parse(json);
var totalNumber = d.total_entries.ToString();
var theId = d.appointment_types[0].id.ToString();
你试过什么?
推荐阅读
- javascript - 在井字游戏中更改游戏模式 [The Odin Project]
- android - 使用 ViewPager2 和 TabLayout 的 Android 数据加载策略
- qt - 在 Qt .pro 文件中添加构建步骤
- python - 在 Pandas 中创建一个引用字典和其他列的新列
- php - 如何限制元素形式的基本插件中的字符长度
- git - vscode 版本控制始终跟踪桌面中的更改
- javascript - 为什么 create-react-app 使用其 babel 配置来评估本地链接的 npm 模块?
- reactjs - chartjs cutoutPercentage 和 tooltips 在 nextjs 中不起作用
- excel - 基于动态范围的 Excel SUM
- flutter - Flutter RefreshIndicator 指示但不刷新