diff --git a/indra/newview/lltranslate.cpp b/indra/newview/lltranslate.cpp index c818251ffa3e71fd205cdf4d0fd6f3eb70b7f765..27c4b84820f16049bd1b66fafc31861fc9935c64 100644 --- a/indra/newview/lltranslate.cpp +++ b/indra/newview/lltranslate.cpp @@ -346,13 +346,13 @@ class LLGoogleTranslationHandler : public LLTranslationAPIHandler private: static void parseErrorResponse( - const boost::json::object &root, - int &status, - std::string &err_msg); + const boost::json::object& root, + int& status, + std::string& err_msg); static bool parseTranslation( - const boost::json::object &root, - std::string &translation, - std::string &detected_lang); + const boost::json::object& root, + std::string& translation, + std::string& detected_lang); static std::string getAPIKey(); }; @@ -432,9 +432,9 @@ bool LLGoogleTranslationHandler::isConfigured() const // static void LLGoogleTranslationHandler::parseErrorResponse( - const boost::json::object &root, - int &status, - std::string &err_msg) + const boost::json::object& root, + int& status, + std::string& err_msg) { boost::json::error_code ec; const boost::json::value* error = root.if_contains("error"); @@ -456,11 +456,11 @@ void LLGoogleTranslationHandler::parseErrorResponse( // static bool LLGoogleTranslationHandler::parseTranslation( - const boost::json::object &root, - std::string &translation, - std::string &detected_lang) + const boost::json::object& root, + std::string& translation, + std::string& detected_lang) { - // Json is prone to aborting the program on failed assertions, + // Boost.Json will throw on failed assertions, // so be super-careful and verify the response format. const boost::json::value* data = root.if_contains("data"); if (!data || !data->is_object()) @@ -470,9 +470,9 @@ bool LLGoogleTranslationHandler::parseTranslation( const boost::json::value* translations = data->as_object().if_contains("translations"); if (!translations || !translations->is_array() || translations->as_array().empty()) - { - return false; - } + { + return false; + } const boost::json::object* first = translations->at(0).if_object(); if (!first) @@ -715,7 +715,6 @@ bool LLAzureTranslationHandler::parseResponse( } // Request succeeded, extract translation from the response. - const boost::json::object* data = root_array->at(0).if_object(); if (!data) { @@ -727,6 +726,7 @@ bool LLAzureTranslationHandler::parseResponse( { return false; } + const boost::json::value* translations = data->if_contains("translations"); if (!translations->is_array() || translations->as_array().empty()) { diff --git a/indra/newview/lltranslate.h b/indra/newview/lltranslate.h index 4a5d80737c022542ad02b9be1c913676a2f7dab2..30fb8d74df2ed8dfae984fca767c9fbf93081943 100644 --- a/indra/newview/lltranslate.h +++ b/indra/newview/lltranslate.h @@ -32,11 +32,6 @@ #include "llsingleton.h" -namespace Json -{ - class Value; -} - class LLTranslationAPIHandler; /** * Entry point for machine translation services.