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/RecognizeBusinessCardResult.h>
18 #include <json/json.h>
19 
20 using namespace AlibabaCloud::Ocr;
21 using namespace AlibabaCloud::Ocr::Model;
22 
RecognizeBusinessCardResult()23 RecognizeBusinessCardResult::RecognizeBusinessCardResult() :
24 	ServiceResult()
25 {}
26 
RecognizeBusinessCardResult(const std::string & payload)27 RecognizeBusinessCardResult::RecognizeBusinessCardResult(const std::string &payload) :
28 	ServiceResult()
29 {
30 	parse(payload);
31 }
32 
~RecognizeBusinessCardResult()33 RecognizeBusinessCardResult::~RecognizeBusinessCardResult()
34 {}
35 
parse(const std::string & payload)36 void RecognizeBusinessCardResult::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["Name"].isNull())
44 		data_.name = dataNode["Name"].asString();
45 		auto allCompanies = dataNode["Companies"]["Company"];
46 		for (auto value : allCompanies)
47 			data_.companies.push_back(value.asString());
48 		auto allDepartments = dataNode["Departments"]["Department"];
49 		for (auto value : allDepartments)
50 			data_.departments.push_back(value.asString());
51 		auto allTitles = dataNode["Titles"]["Title"];
52 		for (auto value : allTitles)
53 			data_.titles.push_back(value.asString());
54 		auto allCellPhoneNumbers = dataNode["CellPhoneNumbers"]["CellPhoneNumber"];
55 		for (auto value : allCellPhoneNumbers)
56 			data_.cellPhoneNumbers.push_back(value.asString());
57 		auto allOfficePhoneNumbers = dataNode["OfficePhoneNumbers"]["OfficePhoneNumber"];
58 		for (auto value : allOfficePhoneNumbers)
59 			data_.officePhoneNumbers.push_back(value.asString());
60 		auto allAddresses = dataNode["Addresses"]["Address"];
61 		for (auto value : allAddresses)
62 			data_.addresses.push_back(value.asString());
63 		auto allEmails = dataNode["Emails"]["Email"];
64 		for (auto value : allEmails)
65 			data_.emails.push_back(value.asString());
66 
67 }
68 
getData() const69 RecognizeBusinessCardResult::Data RecognizeBusinessCardResult::getData()const
70 {
71 	return data_;
72 }
73 
74