QueryDevicePropertyStatusResult.cc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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/iot/model/QueryDevicePropertyStatusResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Iot;
  19. using namespace AlibabaCloud::Iot::Model;
  20. QueryDevicePropertyStatusResult::QueryDevicePropertyStatusResult() :
  21. ServiceResult()
  22. {}
  23. QueryDevicePropertyStatusResult::QueryDevicePropertyStatusResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. QueryDevicePropertyStatusResult::~QueryDevicePropertyStatusResult()
  29. {}
  30. void QueryDevicePropertyStatusResult::parse(const std::string &payload)
  31. {
  32. Json::CharReaderBuilder builder;
  33. Json::CharReader *reader = builder.newCharReader();
  34. Json::Value *val;
  35. Json::Value value;
  36. JSONCPP_STRING *errs;
  37. reader->parse(payload.data(), payload.data() + payload.size(), val, errs);
  38. value = *val;
  39. setRequestId(value["RequestId"].asString());
  40. auto dataNode = value["Data"];
  41. auto allList = value["List"]["PropertyStatusInfo"];
  42. for (auto value : allList)
  43. {
  44. Data::PropertyStatusInfo propertyStatusInfoObject;
  45. if(!value["Unit"].isNull())
  46. propertyStatusInfoObject.unit = value["Unit"].asString();
  47. if(!value["Identifier"].isNull())
  48. propertyStatusInfoObject.identifier = value["Identifier"].asString();
  49. if(!value["DataType"].isNull())
  50. propertyStatusInfoObject.dataType = value["DataType"].asString();
  51. if(!value["Time"].isNull())
  52. propertyStatusInfoObject.time = value["Time"].asString();
  53. if(!value["Value"].isNull())
  54. propertyStatusInfoObject.value = value["Value"].asString();
  55. if(!value["Name"].isNull())
  56. propertyStatusInfoObject.name = value["Name"].asString();
  57. data_.list.push_back(propertyStatusInfoObject);
  58. }
  59. if(!value["Success"].isNull())
  60. success_ = value["Success"].asString() == "true";
  61. if(!value["Code"].isNull())
  62. code_ = value["Code"].asString();
  63. if(!value["ErrorMessage"].isNull())
  64. errorMessage_ = value["ErrorMessage"].asString();
  65. }
  66. QueryDevicePropertyStatusResult::Data QueryDevicePropertyStatusResult::getData()const
  67. {
  68. return data_;
  69. }
  70. std::string QueryDevicePropertyStatusResult::getErrorMessage()const
  71. {
  72. return errorMessage_;
  73. }
  74. std::string QueryDevicePropertyStatusResult::getCode()const
  75. {
  76. return code_;
  77. }
  78. bool QueryDevicePropertyStatusResult::getSuccess()const
  79. {
  80. return success_;
  81. }