我有一个如下的json:
"[{"a":"b","c":"d"},{"a":"e","c":"f"},{"a":"g","c":"h"}]"
现在我想将其反序列化为匿名类型“foo”的对象列表
var foo=new { a=string.empty , c=string.empty };
代码是:
ServiceStackJsonSerializer Jserializer = new ServiceStackJsonSerializer();
dynamic foos = Jserializer.Deserialize<List<foo.GetType()>>(jsonString);
但不工作。
更新 :
替换ServiceStack
和JavascriptSerializer
传递dictionary[]
解决了问题,无需anonymous
键入
JavaScriptSerializer jSerializer = new JavaScriptSerializer();
var Foos = jSerializer.Deserialize<Dictionary<string, object>[]>(jsonString);