我将直接在GET请求中返回对象,如下所示。
Ok(object);
and the response json is given as,
json data-->
{
"id":"1",
"name":"testname"
}
我想为这个json添加更多细节
- >
{
success:"true",
messageDetails:"The response is returned by the service",
data:{}
}
如何做到这一点?
我可以把所有的东西都放在Ok(对象)吗?
答案 0 :(得分:1)
您可以使用anonymous type,例如:
object data = new { id = 1, name = "testname" };
return Ok(new
{
success = "true",
messageDetails = "The response is returned by the service",
data
});