我使用这个代码反序列化JSON字符串对象:嵌套的JSON字符串转换为自定义对象
var account = JsonConvert.DeserializeObject<LdapAccount>(result.ToString());
我收到此错误:
Error reading string. Unexpected token: StartArray. Path 'mail', line 8, position 12.
我知道这是因为嵌套在JSON中,但不知道如何解决。我只关心我的自定义类中的属性。
JSON字符串:
{
"DN": "cn=jdoe,ou=test,dc=foo,dc=com",
"objectClass": [
"inetOrgPerson",
"organizationalPerson",
"person"
],
"mail": [
"[email protected]"
],
"sn": [
"Doe"
],
"givenName": [
"John"
],
"uid": [
"jdoe"
],
"cn": [
"jdoe"
],
"userPassword": [
"xxx"
]
}
我的类:
public class Account
{
public string CID { get; set; }
public string jsonrpc { get; set; }
public string id { get; set; }
public string mail { get; set; }
public string uid { get; set; }
public string userPassword { get; set; }
}