gpt4 book ai didi

c# - 解析值 : [ 时遇到意外字符

转载 作者:太空宇宙 更新时间:2023-11-03 12:00:31 26 4
gpt4 key购买 nike

我的JSON如下

{
"@odata.context":"https://graph.microsoft.com/V1.0/$metadata#users",
"value":[
{
"businessPhones":[

],
"displayName":"dee",
"givenName":null,
"jobTitle":null,
"mail":"<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="71464831161c10181d5f121e1c" rel="noreferrer noopener nofollow">[email protected]</a>",
"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":"<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1170757c787f516674733f7e7f7c7872637e627e77653f727e7c" rel="noreferrer noopener nofollow">[email protected]</a>",
"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":"<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="553431383c3b1526383427213a3239307b363a38" rel="noreferrer noopener nofollow">[email protected]</a>",
"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":"<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="95f4e3d5e6f8f4e7e1faf2f9f0bbf6faf8" rel="noreferrer noopener nofollow">[email protected]</a>",
"id":"6837-08-449-a6ab-78b"
}
]
}

我使用以下代码将 json 转换为对象列表

MyObject obj = JsonConvert.DeserializeObject<MyObject>(members);

MyObject类如下

public class MyError
{
public List<values> value;
}
public class values
{
public string id;
public string userPrincipalName;
public string surname;
public string preferredLanguage;
public string officeLocation;
public string mobilePhone;
public string mail;
public string jobTitle;
public string givenName;
public string displayName;
public string businessPhones;

}

转换时出现以下错误

Unexpected character encountered while parsing value: [. Path 'value[0].businessPhones', line 1, position 97.

当我删除公共(public)字符串businessPhones时;从类中,其余数据被解析到对象列表。但实际上我也需要商务电话

最佳答案

正如一些人指出的那样,您应该将 businessPhones 声明为数组:

public string[] businessPhones;

关于c# - 解析值 : [ 时遇到意外字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57247286/

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