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 17 #include <alibabacloud/ocr/model/RecognizeBusinessLicenseResult.h> 18 #include <json/json.h> 19 20 using namespace AlibabaCloud::Ocr; 21 using namespace AlibabaCloud::Ocr::Model; 22 RecognizeBusinessLicenseResult()23RecognizeBusinessLicenseResult::RecognizeBusinessLicenseResult() : 24 ServiceResult() 25 {} 26 RecognizeBusinessLicenseResult(const std::string & payload)27RecognizeBusinessLicenseResult::RecognizeBusinessLicenseResult(const std::string &payload) : 28 ServiceResult() 29 { 30 parse(payload); 31 } 32 ~RecognizeBusinessLicenseResult()33RecognizeBusinessLicenseResult::~RecognizeBusinessLicenseResult() 34 {} 35 parse(const std::string & payload)36void RecognizeBusinessLicenseResult::parse(const std::string &payload) 37 { 38 Json::Reader reader; 39 Json::Value value; 40 reader.parse(payload, value); 41 setRequestId(value["RequestId"].asString()); 42 auto dataNode = value["Data"]; 43 if(!dataNode["Angle"].isNull()) 44 data_.angle = std::stof(dataNode["Angle"].asString()); 45 if(!dataNode["RegisterNumber"].isNull()) 46 data_.registerNumber = dataNode["RegisterNumber"].asString(); 47 if(!dataNode["Name"].isNull()) 48 data_.name = dataNode["Name"].asString(); 49 if(!dataNode["Type"].isNull()) 50 data_.type = dataNode["Type"].asString(); 51 if(!dataNode["LegalPerson"].isNull()) 52 data_.legalPerson = dataNode["LegalPerson"].asString(); 53 if(!dataNode["EstablishDate"].isNull()) 54 data_.establishDate = dataNode["EstablishDate"].asString(); 55 if(!dataNode["ValidPeriod"].isNull()) 56 data_.validPeriod = dataNode["ValidPeriod"].asString(); 57 if(!dataNode["Address"].isNull()) 58 data_.address = dataNode["Address"].asString(); 59 if(!dataNode["Capital"].isNull()) 60 data_.capital = dataNode["Capital"].asString(); 61 if(!dataNode["Business"].isNull()) 62 data_.business = dataNode["Business"].asString(); 63 auto emblemNode = dataNode["Emblem"]; 64 if(!emblemNode["Top"].isNull()) 65 data_.emblem.top = std::stoi(emblemNode["Top"].asString()); 66 if(!emblemNode["Left"].isNull()) 67 data_.emblem.left = std::stoi(emblemNode["Left"].asString()); 68 if(!emblemNode["Height"].isNull()) 69 data_.emblem.height = std::stoi(emblemNode["Height"].asString()); 70 if(!emblemNode["Width"].isNull()) 71 data_.emblem.width = std::stoi(emblemNode["Width"].asString()); 72 auto titleNode = dataNode["Title"]; 73 if(!titleNode["Top"].isNull()) 74 data_.title.top = std::stoi(titleNode["Top"].asString()); 75 if(!titleNode["Left"].isNull()) 76 data_.title.left = std::stoi(titleNode["Left"].asString()); 77 if(!titleNode["Height"].isNull()) 78 data_.title.height = std::stoi(titleNode["Height"].asString()); 79 if(!titleNode["Width"].isNull()) 80 data_.title.width = std::stoi(titleNode["Width"].asString()); 81 auto stampNode = dataNode["Stamp"]; 82 if(!stampNode["Top"].isNull()) 83 data_.stamp.top = std::stoi(stampNode["Top"].asString()); 84 if(!stampNode["Left"].isNull()) 85 data_.stamp.left = std::stoi(stampNode["Left"].asString()); 86 if(!stampNode["Height"].isNull()) 87 data_.stamp.height = std::stoi(stampNode["Height"].asString()); 88 if(!stampNode["Width"].isNull()) 89 data_.stamp.width = std::stoi(stampNode["Width"].asString()); 90 auto qRCodeNode = dataNode["QRCode"]; 91 if(!qRCodeNode["Top"].isNull()) 92 data_.qRCode.top = std::stoi(qRCodeNode["Top"].asString()); 93 if(!qRCodeNode["Left"].isNull()) 94 data_.qRCode.left = std::stoi(qRCodeNode["Left"].asString()); 95 if(!qRCodeNode["Height"].isNull()) 96 data_.qRCode.height = std::stoi(qRCodeNode["Height"].asString()); 97 if(!qRCodeNode["Width"].isNull()) 98 data_.qRCode.width = std::stoi(qRCodeNode["Width"].asString()); 99 100 } 101 getData() const102RecognizeBusinessLicenseResult::Data RecognizeBusinessLicenseResult::getData()const 103 { 104 return data_; 105 } 106 107