我的 JSON 如下
{
"@odata.context":"https://graph.microsoft.com/V1.0/$metadata#users",
"value":[
{
"businessPhones":[
],
"displayName":"dee",
"givenName":null,
"jobTitle":null,
"mail":"79@gmail.com",
"mobilePhone":null,
"officeLocation":null,
"preferredLanguage":null,
"surname":null,
"userPrincipalName":"79_gmail.com#EXT#@web.onmicrosoft.com",
"id":"08fab3-6f-4dc9-9ffb-6568d172"
},
{
"businessPhones":[
"973"
],
"displayName":"Technologies LLP",
"givenName":"SHA",
"jobTitle":null,
"mail":null,
"mobilePhone":"8762",
"officeLocation":null,
"preferredLanguage":"en-U",
"surname":"SHAI",
"userPrincipalName":"admin@web.onmicrosoft.com",
"id":"2adf-94cd-45-83ef-d0dbf1e36"
},
{
"businessPhones":[
],
"displayName":"admin of smartogle",
"givenName":null,
"jobTitle":null,
"mail":null,
"mobilePhone":null,
"officeLocation":null,
"preferredLanguage":"en-US",
"surname":null,
"userPrincipalName":"admin@smartogle.com",
"id":"1754-d6-40-9ae2-d816063e"
},
{
"businessPhones":[
],
"displayName":"av",
"givenName":null,
"jobTitle":null,
"mail":null,
"mobilePhone":null,
"officeLocation":null,
"preferredLanguage":"en-US",
"surname":null,
"userPrincipalName":"av@smartogle.com",
"id":"6837-08-449-a6ab-78b"
}
]
}
我使用以下代码将 json 转换为对象列表
MyObject obj = JsonConvert.DeserializeObject<MyObject>(members);
MyObject类如下
public class MyError
{
public List<values> value;
}
转换时我收到以下错误
解析值时遇到意外字符:[。路径“value[0].businessPhones”,第 1 行,位置 97。
当我删除公共字符串businessPhones时;从类中,其余数据被解析到对象列表。但实际上我也需要商务电话
茅侃侃
相关分类