无法为从服务接收的 JSON 响应创建映射对象/响应模型。
尝试创建自定义 JsonConverter 但找不到任何合适的方法来帮助解决反序列化问题
以下是我从服务获得的 JSON 响应。
{
"$base": "Collection",
"nodeType": "PROTOCOL",
"Smart Building 0": {
"$base": "Collection",
"nodeType": "NETWORK",
"truncated": "true"
},
"Smart Building 1": {
"$base": "Collection",
"nodeType": "NETWORK",
"truncated": "true"
},
"Smart Building 2": {
"$base": "Collection",
"nodeType": "NETWORK",
"truncated": "true"
}
}
示例 1:- 相同的服务可以返回以下 JSON 格式
{
"$base": "Collection",
"nodeType": "PROTOCOL",
"Smart Building 0": {
"$base": "Collection",
"nodeType": "NETWORK",
"truncated": "true"
},
"Smart Building 1": {
"$base": "Collection",
"nodeType": "NETWORK",
"truncated": "true"
}
}
创建 c# 根对象类,以便可以轻松地使用 JsonConvert 进行反序列化