Json.NET可以反序列化吗?
public class C
{
[JsonConstructor]
public C(IEnumerable<KeyValuePair<string,string>> values)
...
}
答案 0 :(得分:0)
只需反序列化为Dictionary<string, string>
并在其上调用ToList()
。
var myJson = @"{""key1"": ""value1"", ""key2"": ""value2""}";
IEnumerable<KeyValuePair<string, string>> myEnumerable;
myEnumerable = JsonConvert.DeserializeObject<Dictionary<string, string>>(myJson).ToList();