/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include #include #include #include #include #include #include using namespace Aws::LexRuntimeV2::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; using namespace Aws; RecognizeTextResult::RecognizeTextResult() { } RecognizeTextResult::RecognizeTextResult(const Aws::AmazonWebServiceResult& result) { *this = result; } RecognizeTextResult& RecognizeTextResult::operator =(const Aws::AmazonWebServiceResult& result) { JsonView jsonValue = result.GetPayload().View(); if(jsonValue.ValueExists("messages")) { Aws::Utils::Array messagesJsonList = jsonValue.GetArray("messages"); for(unsigned messagesIndex = 0; messagesIndex < messagesJsonList.GetLength(); ++messagesIndex) { m_messages.push_back(messagesJsonList[messagesIndex].AsObject()); } } if(jsonValue.ValueExists("sessionState")) { m_sessionState = jsonValue.GetObject("sessionState"); } if(jsonValue.ValueExists("interpretations")) { Aws::Utils::Array interpretationsJsonList = jsonValue.GetArray("interpretations"); for(unsigned interpretationsIndex = 0; interpretationsIndex < interpretationsJsonList.GetLength(); ++interpretationsIndex) { m_interpretations.push_back(interpretationsJsonList[interpretationsIndex].AsObject()); } } if(jsonValue.ValueExists("requestAttributes")) { Aws::Map requestAttributesJsonMap = jsonValue.GetObject("requestAttributes").GetAllObjects(); for(auto& requestAttributesItem : requestAttributesJsonMap) { m_requestAttributes[requestAttributesItem.first] = requestAttributesItem.second.AsString(); } } if(jsonValue.ValueExists("sessionId")) { m_sessionId = jsonValue.GetString("sessionId"); } if(jsonValue.ValueExists("recognizedBotMember")) { m_recognizedBotMember = jsonValue.GetObject("recognizedBotMember"); } const auto& headers = result.GetHeaderValueCollection(); const auto& requestIdIter = headers.find("x-amzn-requestid"); if(requestIdIter != headers.end()) { m_requestId = requestIdIter->second; } return *this; }