簡體   English   中英

使用 oatpp 發送請求負載

[英]sending request payload with oatpp

我是 oatpp 的初學者,正在構建一個 crud 操作演示應用程序。 我只想在 dto 中發送這四個屬性(id、name、email、salary)中的兩個以更改電子郵件服務,在請求有效負載中,如下所示:

{
 "id":"1",
 "email":"email1"
}

您可以通過創建一個包含這兩個字段的單獨 DTO 然后分配值來實現,也可以返回oatpp::Fields<oatpp::Any>

使用 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"}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM