ListMessageAppResult.cc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright 2009-2017 Alibaba Cloud All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <alibabacloud/live/model/ListMessageAppResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Live;
  19. using namespace AlibabaCloud::Live::Model;
  20. ListMessageAppResult::ListMessageAppResult() :
  21. ServiceResult()
  22. {}
  23. ListMessageAppResult::ListMessageAppResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListMessageAppResult::~ListMessageAppResult()
  29. {}
  30. void ListMessageAppResult::parse(const std::string &payload)
  31. {
  32. Json::Reader reader;
  33. Json::Value value;
  34. reader.parse(payload, value);
  35. setRequestId(value["RequestId"].asString());
  36. auto resultNode = value["Result"];
  37. if(!resultNode["HasMore"].isNull())
  38. result_.hasMore = resultNode["HasMore"].asString() == "true";
  39. if(!resultNode["Total"].isNull())
  40. result_.total = std::stoi(resultNode["Total"].asString());
  41. auto allAppListNode = resultNode["AppList"]["appListItem"];
  42. for (auto resultNodeAppListappListItem : allAppListNode)
  43. {
  44. Result::AppListItem appListItemObject;
  45. if(!resultNodeAppListappListItem["AppConfig"].isNull())
  46. appListItemObject.appConfig = resultNodeAppListappListItem["AppConfig"].asString();
  47. if(!resultNodeAppListappListItem["AppId"].isNull())
  48. appListItemObject.appId = resultNodeAppListappListItem["AppId"].asString();
  49. if(!resultNodeAppListappListItem["AppName"].isNull())
  50. appListItemObject.appName = resultNodeAppListappListItem["AppName"].asString();
  51. if(!resultNodeAppListappListItem["CreateTime"].isNull())
  52. appListItemObject.createTime = std::stol(resultNodeAppListappListItem["CreateTime"].asString());
  53. if(!resultNodeAppListappListItem["Extension"].isNull())
  54. appListItemObject.extension = resultNodeAppListappListItem["Extension"].asString();
  55. if(!resultNodeAppListappListItem["Status"].isNull())
  56. appListItemObject.status = std::stoi(resultNodeAppListappListItem["Status"].asString());
  57. result_.appList.push_back(appListItemObject);
  58. }
  59. }
  60. ListMessageAppResult::Result ListMessageAppResult::getResult()const
  61. {
  62. return result_;
  63. }