我想将以下JSON表示反序列化为强类型对象。我能够从c# - > json序列化它,但反之亦然。为什么不能servicestack将此JSON反序列化为C#?
C#
public class Package
{
public Guid Id {get;set;}
public List<string> Email {get;set;}
public List<Items> Items {get;set;}
}
public class Items
{
public string Uri {get;set;}
public int Width {get;set;}
public int Height {get;set;}
}
JSON
{
"Id":"84fd8751-6107-41af-9473-65aae51e042a",
"Email":[
"[email protected]"
],
"Items":"[
{"Uri":"http://localhost/foo.jpg","Width":234,"Height":313},
{"Uri":"http://localhost/bar.jpg","Width":234,"Height":174}]"
}
代码反序列化
var instance = JsonSerializer.DeserializeFromString<Package>(jsonData);
目的instance
被创建,并且有在instance.Items
2个对象,但所有它们的性质是空值。
TIA
这是我脑死了 - JSON项目的价值是由JSON.stringify(项目)在JavaScript中设置 - 我盯着C#这么久... – Jason 2013-04-04 19:58:40