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/RecognizeChinapassportResult.h> 18 #include <json/json.h> 19 20 using namespace AlibabaCloud::Ocr; 21 using namespace AlibabaCloud::Ocr::Model; 22 RecognizeChinapassportResult()23RecognizeChinapassportResult::RecognizeChinapassportResult() : 24 ServiceResult() 25 {} 26 RecognizeChinapassportResult(const std::string & payload)27RecognizeChinapassportResult::RecognizeChinapassportResult(const std::string &payload) : 28 ServiceResult() 29 { 30 parse(payload); 31 } 32 ~RecognizeChinapassportResult()33RecognizeChinapassportResult::~RecognizeChinapassportResult() 34 {} 35 parse(const std::string & payload)36void RecognizeChinapassportResult::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["Authority"].isNull()) 44 data_.authority = dataNode["Authority"].asString(); 45 if(!dataNode["BirthDate"].isNull()) 46 data_.birthDate = dataNode["BirthDate"].asString(); 47 if(!dataNode["BirthDay"].isNull()) 48 data_.birthDay = dataNode["BirthDay"].asString(); 49 if(!dataNode["BirthPlace"].isNull()) 50 data_.birthPlace = dataNode["BirthPlace"].asString(); 51 if(!dataNode["BirthPlaceRaw"].isNull()) 52 data_.birthPlaceRaw = dataNode["BirthPlaceRaw"].asString(); 53 if(!dataNode["Country"].isNull()) 54 data_.country = dataNode["Country"].asString(); 55 if(!dataNode["ExpiryDate"].isNull()) 56 data_.expiryDate = dataNode["ExpiryDate"].asString(); 57 if(!dataNode["ExpiryDay"].isNull()) 58 data_.expiryDay = dataNode["ExpiryDay"].asString(); 59 if(!dataNode["IssueDate"].isNull()) 60 data_.issueDate = dataNode["IssueDate"].asString(); 61 if(!dataNode["IssuePlace"].isNull()) 62 data_.issuePlace = dataNode["IssuePlace"].asString(); 63 if(!dataNode["IssuePlaceRaw"].isNull()) 64 data_.issuePlaceRaw = dataNode["IssuePlaceRaw"].asString(); 65 if(!dataNode["LineZero"].isNull()) 66 data_.lineZero = dataNode["LineZero"].asString(); 67 if(!dataNode["LineOne"].isNull()) 68 data_.lineOne = dataNode["LineOne"].asString(); 69 if(!dataNode["Name"].isNull()) 70 data_.name = dataNode["Name"].asString(); 71 if(!dataNode["NameChinese"].isNull()) 72 data_.nameChinese = dataNode["NameChinese"].asString(); 73 if(!dataNode["NameChineseRaw"].isNull()) 74 data_.nameChineseRaw = dataNode["NameChineseRaw"].asString(); 75 if(!dataNode["PassportNo"].isNull()) 76 data_.passportNo = dataNode["PassportNo"].asString(); 77 if(!dataNode["PersonId"].isNull()) 78 data_.personId = dataNode["PersonId"].asString(); 79 if(!dataNode["Sex"].isNull()) 80 data_.sex = dataNode["Sex"].asString(); 81 if(!dataNode["SourceCountry"].isNull()) 82 data_.sourceCountry = dataNode["SourceCountry"].asString(); 83 if(!dataNode["Success"].isNull()) 84 data_.success = dataNode["Success"].asString() == "true"; 85 if(!dataNode["Type"].isNull()) 86 data_.type = dataNode["Type"].asString(); 87 88 } 89 getData() const90RecognizeChinapassportResult::Data RecognizeChinapassportResult::getData()const 91 { 92 return data_; 93 } 94 95