我是oatpp的初学者,并构建了一个crud operation演示应用程序。我只想在dto中发送这四个属性(id,名称,电子邮件,薪金)中的两个以更改电子邮件服务,如下所示:
{
"id":"1",
"email":"email1"
}
答案 0 :(得分:0)
您可以通过创建一个包含这两个字段的单独的DTO,然后分配值来做到这一点,
或返回oatpp::Fields<oatpp::Any>
。
ENDPOINT("GET", "/", myEndpoint) {
oatpp::Fields<oatpp::Any> responseDto = {
{"id", oatpp::Int32(1)}, //<-- put your id here
{"email", oatpp::String("email1")} //<-- put your email here
};
return createDtoResponse(Status::CODE_200, responseDto);
}
结果:
{"id":1,"email":"email1"}