diff --git a/native/cpp/CommonCpp/NativeModules/MessageOperationsUtilities/MessageOperationsUtilities.cpp b/native/cpp/CommonCpp/NativeModules/MessageOperationsUtilities/MessageOperationsUtilities.cpp --- a/native/cpp/CommonCpp/NativeModules/MessageOperationsUtilities/MessageOperationsUtilities.cpp +++ b/native/cpp/CommonCpp/NativeModules/MessageOperationsUtilities/MessageOperationsUtilities.cpp @@ -72,4 +72,25 @@ std::move(type), std::move(extras)}; } + +std::vector>> +MessageOperationsUtilities::translateStringToClientDBMessageInfo( + std::string rawMessageInfoString) { + folly::dynamic rawMessageInfos = + folly::parseJson(folly::trimWhitespace(rawMessageInfoString)); + if (!rawMessageInfos.isArray()) { + throw std::runtime_error( + "messageInfos is expected to be an array of JSON objects"); + } + std::vector>> clientDBMessageInfos; + for (const auto &messageInfo : rawMessageInfos) { + if (!messageInfo.isObject()) { + throw std::runtime_error( + "encountered messageInfos element that is not JSON object"); + } + clientDBMessageInfos.push_back( + translateRawMessageInfoToClientDBMessageInfo(messageInfo)); + } + return clientDBMessageInfos; +} } // namespace comm