我有这个 DTO:
public class Post
{
public int Id { get; set; }
public string Message { get; set; }
public DateTime CreatedDate { get; set; }
}
然后我在 servicestack 中有一个返回这个 DTO 列表的路由。方法签名如下所示:public IList<Post> GetAllPost()
从这条路线获得结果时,我的 json 看起来像这样:
[3]
0: {
Id: 2
Message: "itworks1"
CreatedDate: "/Date(1367264995010+0200)/"
}-
1: {
Id: 3
Message: "itworks2"
CreatedDate: "/Date(1367265002050+0200)/"
}-
2: {
Id: 4
Message: "itworks3"
CreatedDate: "/Date(1367265006767+0200)/"
}
但是我希望 JSON 输出看起来像这样:
posts
post: {
Id: 2
Message: "itworks1"
CreatedDate: "/Date(1367264995010+0200)/"
}-
post: {
Id: 3
Message: "itworks2"
CreatedDate: "/Date(1367265002050+0200)/"
}-
post: {
Id: 4
Message: "itworks3"
CreatedDate: "/Date(1367265006767+0200)/"
}
使用 servicestack 序列化程序可以做到这一点吗?