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/RecognizeDriverLicenseResult.h>
18 #include <json/json.h>
19 
20 using namespace AlibabaCloud::Ocr;
21 using namespace AlibabaCloud::Ocr::Model;
22 
RecognizeDriverLicenseResult()23 RecognizeDriverLicenseResult::RecognizeDriverLicenseResult() :
24 	ServiceResult()
25 {}
26 
RecognizeDriverLicenseResult(const std::string & payload)27 RecognizeDriverLicenseResult::RecognizeDriverLicenseResult(const std::string &payload) :
28 	ServiceResult()
29 {
30 	parse(payload);
31 }
32 
~RecognizeDriverLicenseResult()33 RecognizeDriverLicenseResult::~RecognizeDriverLicenseResult()
34 {}
35 
parse(const std::string & payload)36 void RecognizeDriverLicenseResult::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 	auto faceResultNode = dataNode["FaceResult"];
44 	if(!faceResultNode["Name"].isNull())
45 		data_.faceResult.name = faceResultNode["Name"].asString();
46 	if(!faceResultNode["LicenseNumber"].isNull())
47 		data_.faceResult.licenseNumber = faceResultNode["LicenseNumber"].asString();
48 	if(!faceResultNode["VehicleType"].isNull())
49 		data_.faceResult.vehicleType = faceResultNode["VehicleType"].asString();
50 	if(!faceResultNode["StartDate"].isNull())
51 		data_.faceResult.startDate = faceResultNode["StartDate"].asString();
52 	if(!faceResultNode["EndDate"].isNull())
53 		data_.faceResult.endDate = faceResultNode["EndDate"].asString();
54 	if(!faceResultNode["IssueDate"].isNull())
55 		data_.faceResult.issueDate = faceResultNode["IssueDate"].asString();
56 	if(!faceResultNode["Address"].isNull())
57 		data_.faceResult.address = faceResultNode["Address"].asString();
58 	if(!faceResultNode["Gender"].isNull())
59 		data_.faceResult.gender = faceResultNode["Gender"].asString();
60 	auto backResultNode = dataNode["BackResult"];
61 	if(!backResultNode["ArchiveNumber"].isNull())
62 		data_.backResult.archiveNumber = backResultNode["ArchiveNumber"].asString();
63 
64 }
65 
getData() const66 RecognizeDriverLicenseResult::Data RecognizeDriverLicenseResult::getData()const
67 {
68 	return data_;
69 }
70 
71