summaryrefslogtreecommitdiff
path: root/indra/llmessage
diff options
context:
space:
mode:
authorRye Mutt <rye@alchemyviewer.org>2024-04-05 19:03:58 -0400
committerGitHub <noreply@github.com>2024-04-06 02:03:58 +0300
commit17e1f3692c5c1e9cbc6ba6895b312a8baae9aec2 (patch)
tree4e9bc0aa51758539dee0f01e53e8909ad71b7b09 /indra/llmessage
parent7dbdfda7d6fc94eda07dd8376fd47260dfd73964 (diff)
Port from JsonCPP to Boost.Json for json parsing and serializing (#1054)
Diffstat (limited to 'indra/llmessage')
-rw-r--r--indra/llmessage/CMakeLists.txt1
-rw-r--r--indra/llmessage/llcorehttputil.cpp39
2 files changed, 16 insertions, 24 deletions
diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt
index 40d08f4f17..5322139304 100644
--- a/indra/llmessage/CMakeLists.txt
+++ b/indra/llmessage/CMakeLists.txt
@@ -10,7 +10,6 @@ include(LLAddBuildTest)
include(Python)
include(Tut)
include(Python)
-include(JsonCpp)
set(llmessage_SOURCE_FILES
llassetstorage.cpp
diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp
index 460740cebc..7619b46fed 100644
--- a/indra/llmessage/llcorehttputil.cpp
+++ b/indra/llmessage/llcorehttputil.cpp
@@ -35,8 +35,7 @@
#include "llsd.h"
#include "llsdjson.h"
#include "llsdserialize.h"
-#include "json/reader.h" // JSON
-#include "json/writer.h" // JSON
+#include "boost/json.hpp" // Boost.Json
#include "llfilesystem.h"
#include "message.h" // for getting the port
@@ -585,15 +584,12 @@ LLSD HttpCoroJSONHandler::handleSuccess(LLCore::HttpResponse * response, LLCore:
}
LLCore::BufferArrayStream bas(body);
- Json::Value jsonRoot;
- try
- {
- bas >> jsonRoot;
- }
- catch (std::runtime_error& e)
+ boost::json::error_code ec;
+ boost::json::value jsonRoot = boost::json::parse(bas, ec);
+ if(ec.failed())
{ // deserialization failed. Record the reason and pass back an empty map for markup.
- status = LLCore::HttpStatus(499, std::string(e.what()));
+ status = LLCore::HttpStatus(499, std::string(ec.what()));
return result;
}
@@ -613,14 +609,11 @@ LLSD HttpCoroJSONHandler::parseBody(LLCore::HttpResponse *response, bool &succes
}
LLCore::BufferArrayStream bas(body);
- Json::Value jsonRoot;
- try
+ boost::json::error_code ec;
+ boost::json::value jsonRoot = boost::json::parse(bas, ec);
+ if (ec.failed())
{
- bas >> jsonRoot;
- }
- catch (std::runtime_error&)
- {
success = false;
return LLSD();
}
@@ -802,12 +795,12 @@ LLSD HttpCoroutineAdapter::postJsonAndSuspend(LLCore::HttpRequest::ptr_t request
{
LLCore::BufferArrayStream outs(rawbody.get());
- Json::Value root = LlsdToJson(body);
- Json::FastWriter writer;
+ auto root = LlsdToJson(body);
+ std::string value = boost::json::serialize(root);
- LL_WARNS("Http::post") << "JSON Generates: \"" << writer.write(root) << "\"" << LL_ENDL;
+ LL_WARNS("Http::post") << "JSON Generates: \"" << value << "\"" << LL_ENDL;
- outs << writer.write(root);
+ outs << value;
}
return postAndSuspend_(request, url, rawbody, options, headers, httpHandler);
@@ -861,11 +854,11 @@ LLSD HttpCoroutineAdapter::putJsonAndSuspend(LLCore::HttpRequest::ptr_t request,
{
LLCore::BufferArrayStream outs(rawbody.get());
- Json::Value root = LlsdToJson(body);
- Json::FastWriter writer;
+ auto root = LlsdToJson(body);
+ std::string value = boost::json::serialize(root);
- LL_WARNS("Http::put") << "JSON Generates: \"" << writer.write(root) << "\"" << LL_ENDL;
- outs << writer.write(root);
+ LL_WARNS("Http::put") << "JSON Generates: \"" << value << "\"" << LL_ENDL;
+ outs << value;
}
return putAndSuspend_(request, url, rawbody, options, headers, httpHandler);