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>>();
}