QueryCoreWordsResult.cc 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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/chatbot/model/QueryCoreWordsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Chatbot;
  19. using namespace AlibabaCloud::Chatbot::Model;
  20. QueryCoreWordsResult::QueryCoreWordsResult() :
  21. ServiceResult()
  22. {}
  23. QueryCoreWordsResult::QueryCoreWordsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. QueryCoreWordsResult::~QueryCoreWordsResult()
  29. {}
  30. void QueryCoreWordsResult::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 allCoreWordsNode = value["CoreWords"]["CoreWord"];
  37. for (auto valueCoreWordsCoreWord : allCoreWordsNode)
  38. {
  39. CoreWord coreWordsObject;
  40. if(!valueCoreWordsCoreWord["CoreWordCode"].isNull())
  41. coreWordsObject.coreWordCode = valueCoreWordsCoreWord["CoreWordCode"].asString();
  42. if(!valueCoreWordsCoreWord["CoreWordName"].isNull())
  43. coreWordsObject.coreWordName = valueCoreWordsCoreWord["CoreWordName"].asString();
  44. if(!valueCoreWordsCoreWord["ModifyTime"].isNull())
  45. coreWordsObject.modifyTime = valueCoreWordsCoreWord["ModifyTime"].asString();
  46. if(!valueCoreWordsCoreWord["CreateTime"].isNull())
  47. coreWordsObject.createTime = valueCoreWordsCoreWord["CreateTime"].asString();
  48. auto allSynonyms = value["Synonyms"]["Synonym"];
  49. for (auto value : allSynonyms)
  50. coreWordsObject.synonyms.push_back(value.asString());
  51. coreWords_.push_back(coreWordsObject);
  52. }
  53. if(!value["PageNumber"].isNull())
  54. pageNumber_ = std::stoi(value["PageNumber"].asString());
  55. if(!value["PageSize"].isNull())
  56. pageSize_ = std::stoi(value["PageSize"].asString());
  57. if(!value["TotalCount"].isNull())
  58. totalCount_ = std::stoi(value["TotalCount"].asString());
  59. }
  60. int QueryCoreWordsResult::getTotalCount()const
  61. {
  62. return totalCount_;
  63. }
  64. std::vector<QueryCoreWordsResult::CoreWord> QueryCoreWordsResult::getCoreWords()const
  65. {
  66. return coreWords_;
  67. }
  68. int QueryCoreWordsResult::getPageSize()const
  69. {
  70. return pageSize_;
  71. }
  72. int QueryCoreWordsResult::getPageNumber()const
  73. {
  74. return pageNumber_;
  75. }