List<T> 序列化与反序列化

[Serializable]
public class OrderHead
{
public String OrderId { get; set; }
public String OrderName { get; set; }
}
[Serializable]
public class OrderTail
{
public String Money { get; set; }
public String Status { get; set; }
}
[Serializable]
public class Order
{
public OrderHead OrderHead { get; set; }
public OrderTail OrderTail { get; set; }
}

static void Main(string[] args)
{

string config = "{OrderHead:{\"OrderId\":\"1\",\"OrderName\":\"Abc\"},OrderTail:{\"Money\":\"134\",\"Status\":\"Send\"}}";
var order = config.ToInstance<Order>();
config = "[{OrderHead:{\"OrderId\":\"1\",\"OrderName\":\"Abc\"},OrderTail:{\"Money\":\"134\",\"Status\":\"Send\"}},{OrderHead:{\"OrderId\":\"2\",\"OrderName\":\"Def\"},OrderTail:{\"Money\":\"235\",\"Status\":\"Paid\"}}]";
var listAA = config.ToInstance<IList<Order>>();

}

posted @ 2016-04-25 10:42  zslm___  阅读(602)  评论(0编辑  收藏  举报