将DirectoryServices SearchResult序列化为JSON

时间:2018-06-05 12:52:03

标签: c# json serialization json.net

我无法在C#中使用Newtonsoft将DirectoryServices SearchResult序列化为JSON。

我希望做这样的事情:

string serialized = JsonConvert.SerializeObject(searchResult.Properties);

期待收到:

{
  "cn": "Some User",
  "accountexpires": 0,
  "msexchuseraccountcontrol": 0,
  "badpasswordtime": 131710299813433259,
  "someTrueArray": [1, 2, 3]
}

相反,我得到了这个(用字符串和整数创建数组):

{
  "cn": ["Some User"],
  "accountexpires": [0],
  "msexchuseraccountcontrol": [0],
  "badpasswordtime": [131710299813433259],
  "someTrueArray": [1, 2, 3]
}

0 个答案:

没有答案