diff --git a/.github/workflows/psv_pipelines.yml b/.github/workflows/psv_pipelines.yml
index cf0a61215..0dc55efae 100644
--- a/.github/workflows/psv_pipelines.yml
+++ b/.github/workflows/psv_pipelines.yml
@@ -27,7 +27,7 @@ jobs:
run: ./scripts/misc/cpplint_ci.sh
shell: bash
- name: Install Ubuntu dependencies
- run: sudo apt-get update && sudo apt-get install -y libboost-all-dev ccache libssl-dev libcurl4-openssl-dev gcc-7 g++-7 --no-install-recommends
+ run: sudo apt-get update && sudo apt-get install -y ccache libssl-dev libcurl4-openssl-dev gcc-7 g++-7 --no-install-recommends
shell: bash
- name: Compile project with cmake and ccache
run: gcc --version && ./scripts/linux/psv/build_psv.sh
@@ -44,7 +44,7 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4
- name: Install Ubuntu dependencies
- run: sudo apt-get update && sudo apt-get install -y libboost-all-dev ccache libssl-dev libcurl4-openssl-dev gcc-9 g++-9 --no-install-recommends
+ run: sudo apt-get update && sudo apt-get install -y ccache libssl-dev libcurl4-openssl-dev gcc-9 g++-9 --no-install-recommends
shell: bash
- name: Compile project with cmake and ccache
run: gcc --version && ./scripts/linux/psv/build_psv.sh
@@ -72,7 +72,7 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4
- name: Install Ubuntu dependencies
- run: sudo apt-get update && sudo apt-get install -y libboost-all-dev libssl-dev libcurl4-openssl-dev gcc-7 g++-7 --no-install-recommends
+ run: sudo apt-get update && sudo apt-get install -y libssl-dev libcurl4-openssl-dev gcc-7 g++-7 --no-install-recommends
shell: bash
- name: Compile project without cache
run: ./scripts/linux/psv/build_psv_no_cache.sh
@@ -87,7 +87,7 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4
- name: Install Ubuntu dependencies
- run: sudo apt-get update && sudo apt-get install -y libboost-all-dev ccache libssl-dev libcurl4-openssl-dev --no-install-recommends
+ run: sudo apt-get update && sudo apt-get install -y ccache libssl-dev libcurl4-openssl-dev --no-install-recommends
shell: bash
- name: Compile project with cmake and ccache
run: gcc --version && ./scripts/linux/psv/build_psv.sh
@@ -104,7 +104,7 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4
- name: Install Ubuntu dependencies
- run: sudo rm /etc/apt/sources.list.d/microsoft-prod.list && sudo add-apt-repository ppa:ubuntu-toolchain-r/test && sudo apt-get update && sudo apt-get install -y libboost-all-dev libssl-dev libcurl4-openssl-dev gcc-13 g++-13 --no-install-recommends
+ run: sudo rm /etc/apt/sources.list.d/microsoft-prod.list && sudo add-apt-repository ppa:ubuntu-toolchain-r/test && sudo apt-get update && sudo apt-get install -y libssl-dev libcurl4-openssl-dev gcc-13 g++-13 --no-install-recommends
shell: bash
- name: Compile project without cache
run: ./scripts/linux/psv/build_psv_no_cache.sh
@@ -121,7 +121,7 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4
- name: Install Ubuntu dependencies
- run: sudo add-apt-repository ppa:ubuntu-toolchain-r/test && sudo apt-get update && sudo apt-get install -y libboost-all-dev ccache libssl-dev libcurl4-openssl-dev gcc-13 g++-13 --no-install-recommends
+ run: sudo add-apt-repository ppa:ubuntu-toolchain-r/test && sudo apt-get update && sudo apt-get install -y ccache libssl-dev libcurl4-openssl-dev gcc-13 g++-13 --no-install-recommends
shell: bash
- name: Compile project with cmake and ccache
run: gcc --version && ./scripts/linux/psv/build_psv.sh
@@ -136,7 +136,7 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4
- name: Install Ubuntu dependencies
- run: sudo apt-get update && sudo apt-get install -y libboost-all-dev libssl-dev libcurl4-openssl-dev --no-install-recommends
+ run: sudo apt-get update && sudo apt-get install -y libssl-dev libcurl4-openssl-dev --no-install-recommends
shell: bash
- name: Compile project without cache
run: ./scripts/linux/psv/build_psv_no_cache.sh
diff --git a/README.md b/README.md
index 6e4ebf78d..e265c1909 100644
--- a/README.md
+++ b/README.md
@@ -72,7 +72,6 @@ The table below lists the dependencies of the Data SDK.
| Boost (headers only) | 1.82.0 |
| LevelDB | 1.21 |
| Snappy | 1.1.7 |
-| RapidJSON | latest |
| Zlib | 1.3.1 |
### Linux dependencies
diff --git a/docs/get-started.md b/docs/get-started.md
index 18d274384..334aa65e1 100644
--- a/docs/get-started.md
+++ b/docs/get-started.md
@@ -71,7 +71,7 @@ cmake --build . --target install
CMake is the main build system. The minimal required version of CMake is 3.9.
-CMake downloads LevelDB, Snappy, RapidJSON, and Boost. To disable downloading, set `OLP_SDK_BUILD_EXTERNAL_DEPS` to `OFF`. For details on CMake flags, see the [related](#cmake-flags) section.
+CMake downloads LevelDB, Snappy, and Boost. To disable downloading, set `OLP_SDK_BUILD_EXTERNAL_DEPS` to `OFF`. For details on CMake flags, see the [related](#cmake-flags) section.
**To build the Data SDK:**
@@ -175,4 +175,4 @@ HERE Data SDK for C++ contains several example programs that demonstrate some of
- [Read example](dataservice-read-catalog-example.md) – demonstrates how to get catalog and partition metadata, as well as partition data.
- [Read example for a stream layer](dataservice-read-from-stream-layer-example.md) – demonstrates how to get data from a stream layer.
- [Cache example](dataservice-cache-example.md) – demonstrates how to get partition data and work with a mutable and protected cache.
-- [Write example](dataservice-write-example.md) – demonstrates how to publish data to the HERE platform.
\ No newline at end of file
+- [Write example](dataservice-write-example.md) – demonstrates how to publish data to the HERE platform.
diff --git a/docs/work-with-data-apis.md b/docs/work-with-data-apis.md
index 9ce4de074..4d727a4b9 100644
--- a/docs/work-with-data-apis.md
+++ b/docs/work-with-data-apis.md
@@ -59,7 +59,7 @@ The example below demonstrates how to use the `olp::client::OlpClient` class fro
}
```
-5. If the check passed and the status of the received `olp::client::HttpResponse` is `olp::http::HttpStatusCode::OK` (that is 200 OK), extract the encoded JSON from the response and parse it using RapidJSON or any other JSON parsing library.
+5. If the check passed and the status of the received `olp::client::HttpResponse` is `olp::http::HttpStatusCode::OK` (that is 200 OK), extract the encoded JSON from the response and parse it using JSON parsing library.
```cpp
std::string response_json;
diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt
index a7d07e2a0..3a0c8bcd5 100644
--- a/external/CMakeLists.txt
+++ b/external/CMakeLists.txt
@@ -48,10 +48,6 @@ set(OLP_SDK_CPP_SNAPPY_TAG "1.1.7")
set(OLP_SDK_CPP_LEVELDB_URL "https://github.com/google/leveldb.git")
set(OLP_SDK_CPP_LEVELDB_TAG "1.21")
-set(OLP_SDK_CPP_RAPIDJSON_URL "https://github.com/Tencent/rapidjson.git")
-# Next commit after that breaks our build
-set(OLP_SDK_CPP_RAPIDJSON_TAG "d621dc9e9c77f81e5c8a35b8dcc16dcd63351321")
-
set(OLP_SDK_CPP_BOOST_URL "https://github.com/boostorg/boost.git")
set(OLP_SDK_CPP_BOOST_TAG "boost-1.82.0")
@@ -73,11 +69,6 @@ if(NOT TARGET GTest AND NOT GTest_FOUND)
add_subdirectory(googletest)
endif()
-find_package(RapidJSON 1.1.0 QUIET)
-if(NOT TARGET RapidJSON AND NOT RapidJSON_FOUND)
- add_subdirectory(rapidjson)
-endif()
-
if(OLP_SDK_ENABLE_DEFAULT_CACHE)
find_package(leveldb QUIET)
if(NOT TARGET leveldb AND NOT leveldb_FOUND)
@@ -97,7 +88,7 @@ if(OLP_SDK_ENABLE_DEFAULT_CACHE_LMDB)
endif()
endif()
-find_package(Boost QUIET)
+find_package(Boost 1.82.0 QUIET)
if(NOT TARGET Boost AND NOT Boost_FOUND)
add_subdirectory(boost)
set(BOOST_ROOT ${EXTERNAL_BOOST_ROOT} PARENT_SCOPE)
diff --git a/external/boost/CMakeLists.txt.boost.in b/external/boost/CMakeLists.txt.boost.in
index 562b89335..eefa47952 100644
--- a/external/boost/CMakeLists.txt.boost.in
+++ b/external/boost/CMakeLists.txt.boost.in
@@ -24,9 +24,11 @@ include(ExternalProject)
ExternalProject_Add(boost-download
GIT_REPOSITORY @OLP_SDK_CPP_BOOST_URL@
GIT_TAG @OLP_SDK_CPP_BOOST_TAG@
- GIT_SUBMODULES libs/any
+ GIT_SUBMODULES libs/align
+ libs/any
libs/assert
libs/config
+ libs/container
libs/container_hash
libs/core
libs/detail
@@ -35,8 +37,10 @@ ExternalProject_Add(boost-download
libs/function_types
libs/headers
libs/integer
+ libs/intrusive
libs/io
libs/iterator
+ libs/json
libs/move
libs/mpl
libs/mp11
@@ -48,12 +52,14 @@ ExternalProject_Add(boost-download
libs/serialization
libs/smart_ptr
libs/static_assert
+ libs/system
libs/throw_exception
libs/tti
libs/type_index
libs/type_traits
libs/utility
libs/uuid
+ libs/variant2
libs/winapi
tools/build
tools/boost_install
diff --git a/external/rapidjson/CMakeLists.txt b/external/rapidjson/CMakeLists.txt
deleted file mode 100644
index b3f504c04..000000000
--- a/external/rapidjson/CMakeLists.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright (C) 2019-2021 HERE Europe B.V.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-# License-Filename: LICENSE
-
-# RapidJSON
-# Download and unpack rapidjson at configure time
-
-configure_file(CMakeLists.txt.rapidjson.in download/CMakeLists.txt)
-
-execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . ${COMMON_GENERATE_FLAGS}
- RESULT_VARIABLE result
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/download)
-if(result)
- message(FATAL_ERROR "CMake step for rapidjson failed: ${result}")
-endif()
-
-execute_process(COMMAND ${CMAKE_COMMAND} --build .
- RESULT_VARIABLE result
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/download)
-if(result)
- message(FATAL_ERROR "Build step for rapidjson failed: ${result}")
-endif()
diff --git a/external/rapidjson/CMakeLists.txt.rapidjson.in b/external/rapidjson/CMakeLists.txt.rapidjson.in
deleted file mode 100644
index e8a3fc727..000000000
--- a/external/rapidjson/CMakeLists.txt.rapidjson.in
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (C) 2019 HERE Europe B.V.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-# License-Filename: LICENSE
-
-cmake_minimum_required(VERSION 3.9)
-
-project(rapidjson-download NONE)
-
-include(ExternalProject)
-ExternalProject_Add(rapidjson
- GIT_REPOSITORY @OLP_SDK_CPP_RAPIDJSON_URL@
- GIT_TAG @OLP_SDK_CPP_RAPIDJSON_TAG@
- GIT_SHALLOW 0
- INSTALL_DIR "@EXTERNAL_BINARY_INSTALL_DIR@"
- CMAKE_ARGS @COMMON_PLATFORM_FLAGS@
- -DCMAKE_INSTALL_PREFIX=
- -DCMAKE_BUILD_TYPE=@CMAKE_BUILD_TYPE@
- -DRAPIDJSON_BUILD_DOC=OFF
- -DRAPIDJSON_BUILD_EXAMPLES=OFF
- -DRAPIDJSON_BUILD_TESTS=OFF
- -DRAPIDJSON_BUILD_THIRDPARTY_GTEST=OFF
- -DRAPIDJSON_ENABLE_INSTRUMENTATION_OPT=OFF
- -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON
- TEST_COMMAND ""
-)
diff --git a/olp-cpp-sdk-authentication/src/AuthenticationClientImpl.cpp b/olp-cpp-sdk-authentication/src/AuthenticationClientImpl.cpp
index eec62c650..0ca44f93c 100644
--- a/olp-cpp-sdk-authentication/src/AuthenticationClientImpl.cpp
+++ b/olp-cpp-sdk-authentication/src/AuthenticationClientImpl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2024 HERE Europe B.V.
+ * Copyright (C) 2020-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,10 +26,9 @@
#include
#include
-#include
-#include
-#include
-#include
+#include
+#include
+#include
#include
#include
#include
@@ -116,17 +115,13 @@ void RetryDelay(const client::RetrySettings& retry_settings, size_t retry) {
client::OlpClient::RequestBodyType GenerateAppleSignInBody(
const AppleSignInProperties& sign_in_properties) {
- rapidjson::StringBuffer data;
- rapidjson::Writer writer(data);
- writer.StartObject();
+ boost::json::object json_object;
- writer.Key(kGrantType);
- writer.String(kAppleGrantType);
+ json_object[kGrantType] = kAppleGrantType;
- auto write_field = [&writer](const char* key, const std::string& value) {
+ auto write_field = [&json_object](const char* key, const std::string& value) {
if (!value.empty()) {
- writer.Key(key);
- writer.String(value.c_str());
+ json_object[key] = value;
}
};
@@ -137,9 +132,8 @@ client::OlpClient::RequestBodyType GenerateAppleSignInBody(
write_field(kCountryCode, sign_in_properties.GetCountryCode());
write_field(kLanguage, sign_in_properties.GetLanguage());
- writer.EndObject();
- auto content = data.GetString();
- return std::make_shared(content, content + data.GetSize());
+ auto content = boost::json::serialize(json_object);
+ return std::make_shared(content.begin(), content.end());
}
client::HttpResponse CallApi(const client::OlpClient& client,
@@ -203,20 +197,26 @@ olp::client::HttpResponse AuthenticationClientImpl::CallAuth(
SignInResult AuthenticationClientImpl::ParseAuthResponse(
int status, std::stringstream& auth_response) {
- auto document = std::make_shared();
- rapidjson::IStreamWrapper stream(auth_response);
- document->ParseStream(stream);
+ boost::json::error_code ec;
+ auto document = boost::json::parse(auth_response, ec);
return std::make_shared(
- status, olp::http::HttpErrorToString(status), document);
+ status, olp::http::HttpErrorToString(status),
+ ec.failed() || !document.is_object()
+ ? nullptr
+ : std::make_shared(
+ std::move(document.as_object())));
}
SignInUserResult AuthenticationClientImpl::ParseUserAuthResponse(
int status, std::stringstream& auth_response) {
- auto document = std::make_shared();
- rapidjson::IStreamWrapper stream(auth_response);
- document->ParseStream(stream);
+ boost::json::error_code ec;
+ auto document = boost::json::parse(auth_response, ec);
return std::make_shared(
- status, olp::http::HttpErrorToString(status), document);
+ status, olp::http::HttpErrorToString(status),
+ ec.failed() || !document.is_object()
+ ? nullptr
+ : std::make_shared(
+ std::move(document.as_object())));
}
template
@@ -361,23 +361,24 @@ client::CancellationToken AuthenticationClientImpl::SignInClient(
TimeResponse AuthenticationClientImpl::ParseTimeResponse(
std::stringstream& payload) {
- rapidjson::Document document;
- rapidjson::IStreamWrapper stream(payload);
- document.ParseStream(stream);
+ boost::json::error_code ec;
+ auto json_value = boost::json::parse(payload, ec);
- if (!document.IsObject()) {
+ if (ec.failed() || !json_value.is_object()) {
return client::ApiError(client::ErrorCode::InternalFailure,
"JSON document root is not an Object type");
}
- const auto timestamp_it = document.FindMember("timestamp");
- if (timestamp_it == document.MemberEnd() || !timestamp_it->value.IsUint()) {
+ auto& object = json_value.as_object();
+ const auto timestamp_it = object.find("timestamp");
+ if (timestamp_it == object.end() || (!timestamp_it->value().is_uint64() &&
+ !timestamp_it->value().is_int64())) {
return client::ApiError(
client::ErrorCode::InternalFailure,
"JSON document must contain timestamp integer field");
}
- return timestamp_it->value.GetUint();
+ return timestamp_it->value().to_number();
}
TimeResponse AuthenticationClientImpl::GetTimeFromServer(
@@ -586,10 +587,14 @@ client::CancellationToken AuthenticationClientImpl::SignUpHereUser(
return client::ApiError(status, response_text);
}
- auto document = std::make_shared();
- document->Parse(response_text.c_str());
+ boost::json::error_code ec;
+ auto document = boost::json::parse(response_text, ec);
return {std::make_shared(
- status, olp::http::HttpErrorToString(status), document)};
+ status, olp::http::HttpErrorToString(status),
+ ec.failed() || !document.is_object()
+ ? nullptr
+ : std::make_shared(
+ std::move(document.as_object())))};
};
return AddTask(settings_.task_scheduler, pending_requests_,
@@ -631,10 +636,14 @@ client::CancellationToken AuthenticationClientImpl::SignOut(
return client::ApiError(status, response_text);
}
- auto document = std::make_shared();
- document->Parse(response_text.c_str());
+ boost::json::error_code ec;
+ auto document = boost::json::parse(response_text, ec);
return {std::make_shared(
- status, olp::http::HttpErrorToString(status), document)};
+ status, olp::http::HttpErrorToString(status),
+ ec.failed() || !document.is_object()
+ ? nullptr
+ : std::make_shared(
+ std::move(document.as_object())))};
};
return AddTask(settings_.task_scheduler, pending_requests_,
@@ -664,24 +673,23 @@ client::CancellationToken AuthenticationClientImpl::IntrospectApp(
auto http_result = client.CallApi(kIntrospectAppEndpoint, "GET", {}, {}, {},
nullptr, {}, context);
- rapidjson::Document document;
- rapidjson::IStreamWrapper stream(http_result.GetRawResponse());
- document.ParseStream(stream);
+ boost::json::error_code ec;
+ auto document = boost::json::parse(http_result.GetRawResponse(), ec);
if (http_result.GetStatus() != http::HttpStatusCode::OK) {
// HttpResult response can be error message or valid json with it.
std::string msg = http_result.GetResponseAsString();
- if (!document.HasParseError() && document.HasMember(Constants::MESSAGE)) {
- msg = document[Constants::MESSAGE].GetString();
+ if (!ec.failed() && document.as_object().contains(Constants::MESSAGE)) {
+ msg = document.as_object()[Constants::MESSAGE].as_string().c_str();
}
return client::ApiError({http_result.GetStatus(), msg});
}
- if (document.HasParseError()) {
+ if (ec.failed() || !document.is_object()) {
return client::ApiError({static_cast(http::ErrorCode::UNKNOWN_ERROR),
"Failed to parse response"});
}
- return GetIntrospectAppResult(document);
+ return GetIntrospectAppResult(document.as_object());
};
return AddTask(settings_.task_scheduler, pending_requests_,
@@ -711,25 +719,27 @@ client::CancellationToken AuthenticationClientImpl::Authorize(
GenerateAuthorizeBody(request),
kApplicationJson, context);
- rapidjson::Document document;
- rapidjson::IStreamWrapper stream(http_result.GetRawResponse());
- document.ParseStream(stream);
+ boost::json::error_code ec;
+ auto document = boost::json::parse(http_result.GetRawResponse(), ec);
if (http_result.GetStatus() != http::HttpStatusCode::OK) {
// HttpResult response can be error message or valid json with it.
std::string msg = http_result.GetResponseAsString();
- if (!document.HasParseError() && document.HasMember(Constants::MESSAGE)) {
- msg = document[Constants::MESSAGE].GetString();
+ if (!ec.failed() && document.as_object().contains(Constants::MESSAGE)) {
+ msg = document.as_object()[Constants::MESSAGE].as_string().c_str();
}
return client::ApiError({http_result.GetStatus(), msg});
- } else if (!document.HasParseError() &&
- document.HasMember(Constants::ERROR_CODE) &&
- document[Constants::ERROR_CODE].IsInt()) {
+ }
+
+ if (!ec.failed() && document.as_object().contains(Constants::ERROR_CODE) &&
+ document.as_object()[Constants::ERROR_CODE].is_int64()) {
std::string msg =
"Error code: " +
- std::to_string(document[Constants::ERROR_CODE].GetInt());
- if (document.HasMember(Constants::MESSAGE)) {
+ std::to_string(
+ document.as_object()[Constants::ERROR_CODE].as_int64());
+ if (document.as_object().contains(Constants::MESSAGE)) {
msg.append(" (");
- msg.append(document[Constants::MESSAGE].GetString());
+ msg.append(
+ document.as_object()[Constants::MESSAGE].as_string().c_str());
msg.append(")");
}
@@ -737,12 +747,12 @@ client::CancellationToken AuthenticationClientImpl::Authorize(
{static_cast(http::ErrorCode::UNKNOWN_ERROR), msg});
}
- if (document.HasParseError()) {
+ if (ec.failed() || !document.is_object()) {
return client::ApiError({static_cast(http::ErrorCode::UNKNOWN_ERROR),
"Failed to parse response"});
}
- return GetAuthorizeResult(document);
+ return GetAuthorizeResult(document.as_object());
};
return AddTask(settings_.task_scheduler, pending_requests_, std::move(task),
@@ -778,237 +788,186 @@ client::CancellationToken AuthenticationClientImpl::GetMyAccount(
client::OlpClient::RequestBodyType AuthenticationClientImpl::GenerateClientBody(
const SignInProperties& properties) {
- rapidjson::StringBuffer data;
- rapidjson::Writer writer(data);
- writer.StartObject();
+ boost::json::object object;
- writer.Key(kGrantType);
- writer.String(kClientGrantType);
+ object[kGrantType] = kClientGrantType;
auto expires_in = static_cast(properties.expires_in.count());
if (expires_in > 0) {
- writer.Key(Constants::EXPIRES_IN);
- writer.Uint(expires_in);
+ object[Constants::EXPIRES_IN] = expires_in;
}
if (properties.scope) {
- writer.Key(kScope);
- writer.String(properties.scope.get().c_str());
+ object[kScope] = properties.scope.get();
}
if (properties.device_id) {
- writer.Key(kDeviceId);
- writer.String(properties.device_id.get().c_str());
+ object[kDeviceId] = properties.device_id.get();
}
- writer.EndObject();
- auto content = data.GetString();
- return std::make_shared(content, content + data.GetSize());
+ auto content = boost::json::serialize(object);
+ return std::make_shared(content.begin(), content.end());
}
client::OlpClient::RequestBodyType AuthenticationClientImpl::GenerateUserBody(
const UserProperties& properties) {
- rapidjson::StringBuffer data;
- rapidjson::Writer writer(data);
- writer.StartObject();
+ boost::json::object object;
- writer.Key(kGrantType);
- writer.String(kUserGrantType);
+ object[kGrantType] = kUserGrantType;
if (!properties.email.empty()) {
- writer.Key(kEmail);
- writer.String(properties.email.c_str());
+ object[kEmail] = properties.email;
}
if (!properties.password.empty()) {
- writer.Key(kPassword);
- writer.String(properties.password.c_str());
+ object[kPassword] = properties.password;
}
if (properties.expires_in > 0) {
- writer.Key(Constants::EXPIRES_IN);
- writer.Uint(properties.expires_in);
+ object[Constants::EXPIRES_IN] = properties.expires_in;
}
- writer.EndObject();
- auto content = data.GetString();
- return std::make_shared(content, content + data.GetSize());
+
+ auto content = boost::json::serialize(object);
+ return std::make_shared(content.begin(), content.end());
}
client::OlpClient::RequestBodyType
AuthenticationClientImpl::GenerateFederatedBody(
const FederatedSignInType type, const FederatedProperties& properties) {
- rapidjson::StringBuffer data;
- rapidjson::Writer writer(data);
- writer.StartObject();
+ boost::json::object object;
- writer.Key(kGrantType);
switch (type) {
case FederatedSignInType::FacebookSignIn:
- writer.String(kFacebookGrantType);
+ object[kGrantType] = kFacebookGrantType;
break;
case FederatedSignInType::ArcgisSignIn:
- writer.String(kArcgisGrantType);
+ object[kGrantType] = kArcgisGrantType;
break;
default:
return nullptr;
}
if (!properties.access_token.empty()) {
- writer.Key(Constants::ACCESS_TOKEN);
- writer.String(properties.access_token.c_str());
+ object[Constants::ACCESS_TOKEN] = properties.access_token;
}
if (!properties.country_code.empty()) {
- writer.Key(kCountryCode);
- writer.String(properties.country_code.c_str());
+ object[kCountryCode] = properties.country_code;
}
if (!properties.language.empty()) {
- writer.Key(kLanguage);
- writer.String(properties.language.c_str());
+ object[kLanguage] = properties.language;
}
if (!properties.email.empty()) {
- writer.Key(kEmail);
- writer.String(properties.email.c_str());
+ object[kEmail] = properties.email;
}
if (properties.expires_in > 0) {
- writer.Key(Constants::EXPIRES_IN);
- writer.Uint(properties.expires_in);
+ object[Constants::EXPIRES_IN] = properties.expires_in;
}
- writer.EndObject();
- auto content = data.GetString();
- return std::make_shared(content, content + data.GetSize());
+ auto content = boost::json::serialize(object);
+ return std::make_shared(content.begin(), content.end());
}
client::OlpClient::RequestBodyType
AuthenticationClientImpl::GenerateRefreshBody(
const RefreshProperties& properties) {
- rapidjson::StringBuffer data;
- rapidjson::Writer writer(data);
- writer.StartObject();
+ boost::json::object object;
- writer.Key(kGrantType);
- writer.String(kRefreshGrantType);
+ object[kGrantType] = kRefreshGrantType;
if (!properties.access_token.empty()) {
- writer.Key(Constants::ACCESS_TOKEN);
- writer.String(properties.access_token.c_str());
+ object[Constants::ACCESS_TOKEN] = properties.access_token;
}
if (!properties.refresh_token.empty()) {
- writer.Key(Constants::REFRESH_TOKEN);
- writer.String(properties.refresh_token.c_str());
+ object[Constants::REFRESH_TOKEN] = properties.refresh_token;
}
if (properties.expires_in > 0) {
- writer.Key(Constants::EXPIRES_IN);
- writer.Uint(properties.expires_in);
+ object[Constants::EXPIRES_IN] = properties.expires_in;
}
- writer.EndObject();
- auto content = data.GetString();
- return std::make_shared(content, content + data.GetSize());
+
+ auto content = boost::json::serialize(object);
+ return std::make_shared(content.begin(), content.end());
}
client::OlpClient::RequestBodyType AuthenticationClientImpl::GenerateSignUpBody(
const SignUpProperties& properties) {
- rapidjson::StringBuffer data;
- rapidjson::Writer writer(data);
- writer.StartObject();
+ boost::json::object object;
if (!properties.email.empty()) {
- writer.Key(kEmail);
- writer.String(properties.email.c_str());
+ object[kEmail] = properties.email;
}
if (!properties.password.empty()) {
- writer.Key(kPassword);
- writer.String(properties.password.c_str());
+ object[kPassword] = properties.password;
}
if (!properties.date_of_birth.empty()) {
- writer.Key(kDateOfBirth);
- writer.String(properties.date_of_birth.c_str());
+ object[kDateOfBirth] = properties.date_of_birth;
}
if (!properties.first_name.empty()) {
- writer.Key(kFirstName);
- writer.String(properties.first_name.c_str());
+ object[kFirstName] = properties.first_name;
}
if (!properties.last_name.empty()) {
- writer.Key(kLastName);
- writer.String(properties.last_name.c_str());
+ object[kLastName] = properties.last_name;
}
if (!properties.country_code.empty()) {
- writer.Key(kCountryCode);
- writer.String(properties.country_code.c_str());
+ object[kCountryCode] = properties.country_code;
}
if (!properties.language.empty()) {
- writer.Key(kLanguage);
- writer.String(properties.language.c_str());
+ object[kLanguage] = properties.language;
}
if (properties.marketing_enabled) {
- writer.Key(kMarketingEnabled);
- writer.Bool(true);
+ object[kMarketingEnabled] = true;
}
if (!properties.phone_number.empty()) {
- writer.Key(kPhoneNumber);
- writer.String(properties.phone_number.c_str());
+ object[kPhoneNumber] = properties.phone_number;
}
if (!properties.realm.empty()) {
- writer.Key(kRealm);
- writer.String(properties.realm.c_str());
+ object[kRealm] = properties.realm;
}
if (!properties.invite_token.empty()) {
- writer.Key(kInviteToken);
- writer.String(properties.invite_token.c_str());
+ object[kInviteToken] = properties.invite_token;
}
- writer.EndObject();
- auto content = data.GetString();
- return std::make_shared(content, content + data.GetSize());
+ auto content = boost::json::serialize(object);
+ return std::make_shared(content.begin(), content.end());
}
client::OlpClient::RequestBodyType
AuthenticationClientImpl::GenerateAcceptTermBody(
const std::string& reacceptance_token) {
- rapidjson::StringBuffer data;
- rapidjson::Writer writer(data);
- writer.StartObject();
+ boost::json::object object;
- writer.Key(kTermsReacceptanceToken);
- writer.String(reacceptance_token.c_str());
+ object[kTermsReacceptanceToken] = reacceptance_token;
- writer.EndObject();
- auto content = data.GetString();
- return std::make_shared(content, content + data.GetSize());
+ auto content = boost::json::serialize(object);
+ return std::make_shared(content.begin(), content.end());
}
client::OlpClient::RequestBodyType
AuthenticationClientImpl::GenerateAuthorizeBody(
const AuthorizeRequest& properties) {
- rapidjson::StringBuffer data;
- rapidjson::Writer writer(data);
- writer.StartObject();
- writer.Key(kServiceId);
- writer.String(properties.GetServiceId().c_str());
- writer.Key(kActions);
- writer.StartArray();
- for (const auto& action : properties.GetActions()) {
- writer.StartObject();
- writer.Key(kAction);
- writer.String(action.first.c_str());
- if (!action.second.empty()) {
- writer.Key(kResource);
- writer.String(action.second.c_str());
+ boost::json::object object;
+
+ object[kServiceId] = properties.GetServiceId();
+
+ {
+ boost::json::array actions;
+ for (const auto& action : properties.GetActions()) {
+ boost::json::object action_value;
+ action_value[kAction] = action.first;
+ if (!action.second.empty()) {
+ action_value.emplace(kResource, action.second);
+ }
+ actions.emplace_back(std::move(action_value));
}
- writer.EndObject();
+ object.emplace(kActions, std::move(actions));
}
- writer.EndArray();
- writer.Key(kDiagnostics);
- writer.Bool(properties.GetDiagnostics());
+ object[kDiagnostics] = properties.GetDiagnostics();
// default value is 'and', ignore parameter if operator type is 'and'
if (properties.GetOperatorType() ==
AuthorizeRequest::DecisionOperatorType::kOr) {
- writer.Key(kOperator);
- writer.String("or");
+ object[kOperator] = "or";
}
- writer.EndObject();
- auto content = data.GetString();
- return std::make_shared(content, content + data.GetSize());
+ auto content = boost::json::serialize(object);
+ return std::make_shared(content.begin(), content.end());
}
std::string AuthenticationClientImpl::GenerateUid() const {
diff --git a/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.cpp b/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.cpp
index 3ff6616c2..ac265fee5 100644
--- a/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.cpp
+++ b/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2024 HERE Europe B.V.
+ * Copyright (C) 2020-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,10 +24,9 @@
#include
#include
-#include
-#include
-#include
-#include
+#include
+#include
+#include
#include "Constants.h"
#include "ResponseFromJsonBuilder.h"
#include "olp/core/http/NetworkResponse.h"
@@ -70,25 +69,25 @@ std::string Base64Encode(const Crypto::Sha256Digest& digest) {
return ret;
}
-Response Parse(client::HttpResponse& http_response) {
- rapidjson::IStreamWrapper stream(http_response.GetRawResponse());
- rapidjson::Document document;
- document.ParseStream(stream);
+Response Parse(client::HttpResponse& http_response) {
+ boost::json::error_code ec;
+ auto document = boost::json::parse(http_response.GetRawResponse(), ec);
if (http_response.GetStatus() != http::HttpStatusCode::OK) {
// HttpResult response can be error message or valid json with it.
std::string msg = http_response.GetResponseAsString();
- if (!document.HasParseError() && document.HasMember(Constants::MESSAGE)) {
- msg = document[Constants::MESSAGE].GetString();
+ if (!ec.failed() && document.is_object() &&
+ document.as_object().contains(Constants::MESSAGE)) {
+ msg = document.as_object()[Constants::MESSAGE].get_string().c_str();
}
return client::ApiError({http_response.GetStatus(), msg});
}
- if (document.HasParseError()) {
+ if (ec.failed() || !document.is_object()) {
return client::ApiError({static_cast(http::ErrorCode::UNKNOWN_ERROR),
"Failed to parse response"});
}
- return Response(std::move(document));
+ return {std::move(document).as_object()};
}
} // namespace
@@ -137,7 +136,7 @@ boost::optional GetTimestampFromHeaders(
return boost::none;
}
-IntrospectAppResult GetIntrospectAppResult(const rapidjson::Document& doc) {
+IntrospectAppResult GetIntrospectAppResult(const boost::json::object& doc) {
return ResponseFromJsonBuilder::Build(doc)
.Value(Constants::CLIENT_ID, &IntrospectAppResult::SetClientId)
.Value(Constants::NAME, &IntrospectAppResult::SetName)
@@ -168,22 +167,25 @@ DecisionType GetDecision(const std::string& str) {
: DecisionType::kDeny;
}
-std::vector GetDiagnostics(rapidjson::Document& doc) {
+std::vector GetDiagnostics(boost::json::object& doc) {
std::vector results;
- const auto& array = doc[Constants::DIAGNOSTICS].GetArray();
- for (auto& element : array) {
+ auto& array = doc[Constants::DIAGNOSTICS].get_array();
+ for (auto& element_value : array) {
+ auto& element = element_value.get_object();
ActionResult action;
- if (element.HasMember(Constants::DECISION)) {
- action.SetDecision(GetDecision(element[Constants::DECISION].GetString()));
+ if (element.contains(Constants::DECISION)) {
+ action.SetDecision(
+ GetDecision(element[Constants::DECISION].get_string().c_str()));
// get permissions if avialible
- if (element.HasMember(Constants::PERMISSIONS) &&
- element[Constants::PERMISSIONS].IsArray()) {
+ if (element.contains(Constants::PERMISSIONS) &&
+ element[Constants::PERMISSIONS].is_array()) {
std::vector permissions;
const auto& permissions_array =
- element[Constants::PERMISSIONS].GetArray();
+ element[Constants::PERMISSIONS].get_array();
for (auto& permission_element : permissions_array) {
Permission permission =
- ResponseFromJsonBuilder::Build(permission_element)
+ ResponseFromJsonBuilder::Build(
+ permission_element.get_object())
.Value(Constants::ACTION, &Permission::SetAction)
.Value(Constants::DECISION, &Permission::SetDecision,
&GetDecision)
@@ -200,26 +202,27 @@ std::vector GetDiagnostics(rapidjson::Document& doc) {
return results;
}
-AuthorizeResult GetAuthorizeResult(rapidjson::Document& doc) {
+AuthorizeResult GetAuthorizeResult(boost::json::object& doc) {
AuthorizeResult result;
- if (doc.HasMember(Constants::IDENTITY)) {
- auto uris = doc[Constants::IDENTITY].GetObject();
+ if (doc.contains(Constants::IDENTITY)) {
+ auto uris = doc[Constants::IDENTITY].get_object();
- if (uris.HasMember(Constants::CLIENT_ID)) {
- result.SetClientId(uris[Constants::CLIENT_ID].GetString());
- } else if (uris.HasMember(Constants::USER_ID)) {
- result.SetClientId(uris[Constants::USER_ID].GetString());
+ if (uris.contains(Constants::CLIENT_ID)) {
+ result.SetClientId(uris[Constants::CLIENT_ID].get_string().c_str());
+ } else if (uris.contains(Constants::USER_ID)) {
+ result.SetClientId(uris[Constants::USER_ID].get_string().c_str());
}
}
- if (doc.HasMember(Constants::DECISION)) {
- result.SetDecision(GetDecision(doc[Constants::DECISION].GetString()));
+ if (doc.contains(Constants::DECISION)) {
+ result.SetDecision(
+ GetDecision(doc[Constants::DECISION].get_string().c_str()));
}
// get diagnostics if available
- if (doc.HasMember(Constants::DIAGNOSTICS) &&
- doc[Constants::DIAGNOSTICS].IsArray()) {
+ if (doc.contains(Constants::DIAGNOSTICS) &&
+ doc[Constants::DIAGNOSTICS].is_array()) {
result.SetActionResults(GetDiagnostics(doc));
}
return result;
diff --git a/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.h b/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.h
index 2b5af2fc4..e80a76736 100644
--- a/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.h
+++ b/olp-cpp-sdk-authentication/src/AuthenticationClientUtils.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2021 HERE Europe B.V.
+ * Copyright (C) 2020-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@
#include
#include
-#include
+#include
#include "olp/authentication/AuthenticationCredentials.h"
#include "olp/authentication/AuthenticationSettings.h"
@@ -78,7 +78,7 @@ boost::optional GetTimestampFromHeaders(
* @param doc json document.
* @return result for introspect app.
*/
-IntrospectAppResult GetIntrospectAppResult(const rapidjson::Document& doc);
+IntrospectAppResult GetIntrospectAppResult(const boost::json::object& value);
/*
* @brief Convert string representation of decision to DecisionType.
@@ -92,14 +92,14 @@ DecisionType GetDecision(const std::string& str);
* @param doc json document.
* @return result of ActionResults.
*/
-std::vector GetDiagnostics(rapidjson::Document& doc);
+std::vector GetDiagnostics(boost::json::object& value);
/*
* @brief Parse json document to AuthorizeResult type.
* @param doc json document.
* @return result for authorize.
*/
-AuthorizeResult GetAuthorizeResult(rapidjson::Document& doc);
+AuthorizeResult GetAuthorizeResult(boost::json::object& value);
/*
* @brief Parse HTTP response to UserAccountInfoResponse type or error message.
diff --git a/olp-cpp-sdk-authentication/src/BaseResult.cpp b/olp-cpp-sdk-authentication/src/BaseResult.cpp
index edd86f7c9..5f07690d6 100644
--- a/olp-cpp-sdk-authentication/src/BaseResult.cpp
+++ b/olp-cpp-sdk-authentication/src/BaseResult.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2021 HERE Europe B.V.
+ * Copyright (C) 2019-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,8 +19,8 @@
#include "BaseResult.h"
-#include
-#include
+#include
+#include
#include "Constants.h"
#include "olp/core/http/HttpStatusCode.h"
@@ -35,52 +35,49 @@ static const char* ERROR_MESSAGE = "message";
static const char* LINE_END = ".";
BaseResult::BaseResult(int status, std::string error,
- std::shared_ptr json_document)
+ std::shared_ptr json_document)
: status_()
{
status_ = status;
error_.message = std::move(error);
- is_valid_ = (json_document && !json_document->HasParseError());
+ is_valid_ = json_document != nullptr;
// If HTTP error, try to get error details
- if (!HasError() || !is_valid_ || !json_document->HasMember(ERROR_CODE)) {
+ if (!HasError() || !is_valid_ || !json_document->contains(ERROR_CODE)) {
return;
}
// The JSON document has an error code member, so save full JSON content to
// the `full_message_` string.
- rapidjson::StringBuffer buffer;
- rapidjson::Writer writer(buffer);
- json_document->Accept(writer);
- full_message_ = buffer.GetString();
+ full_message_ = boost::json::serialize(*json_document);
- if (json_document->HasMember(ERROR_ID)) {
- error_.error_id = (*json_document)[ERROR_ID].GetString();
+ if (json_document->contains(ERROR_ID)) {
+ error_.error_id = (*json_document)[ERROR_ID].get_string().c_str();
}
// Enhance error message with network response error details
- error_.code = (*json_document)[ERROR_CODE].GetUint();
+ error_.code = (*json_document)[ERROR_CODE].to_number();
- if (!json_document->HasMember(ERROR_MESSAGE)) {
+ if (!json_document->contains(ERROR_MESSAGE)) {
return;
}
- std::string message = (*json_document)[ERROR_MESSAGE].GetString();
- if (!json_document->HasMember(ERROR_FIELDS)) {
+ std::string message = (*json_document)[ERROR_MESSAGE].get_string().c_str();
+ if (!json_document->contains(ERROR_FIELDS)) {
error_.message = message;
return;
}
error_.message = message.substr(0, message.find_first_of(LINE_END) + 1);
- const rapidjson::Value& fields = (*json_document)[ERROR_FIELDS];
- if (fields.GetType() == rapidjson::kArrayType) {
- for (rapidjson::SizeType i = 0u; i < fields.Size(); i++) {
- const rapidjson::Value& field = fields[i];
- if (field.HasMember(ERROR_MESSAGE)) {
+ auto& fields = (*json_document)[ERROR_FIELDS];
+ if (auto* fields_array = fields.if_array()) {
+ for (auto& field : *fields_array) {
+ if (field.is_object() && field.as_object().contains(ERROR_MESSAGE)) {
ErrorField error_field;
- error_field.name = field[FIELD_NAME].GetString();
- error_field.code = field[ERROR_CODE].GetUint();
- error_field.message = field[ERROR_MESSAGE].GetString();
+ error_field.name = field.as_object()[FIELD_NAME].get_string().c_str();
+ error_field.code = field.as_object()[ERROR_CODE].to_number();
+ error_field.message =
+ field.as_object()[ERROR_MESSAGE].get_string().c_str();
error_fields_.emplace_back(error_field);
}
}
diff --git a/olp-cpp-sdk-authentication/src/BaseResult.h b/olp-cpp-sdk-authentication/src/BaseResult.h
index cd581275f..802bb2605 100644
--- a/olp-cpp-sdk-authentication/src/BaseResult.h
+++ b/olp-cpp-sdk-authentication/src/BaseResult.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2021 HERE Europe B.V.
+ * Copyright (C) 2019-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@
#include
#include
-#include
+#include
#include "olp/authentication/ErrorResponse.h"
@@ -33,7 +33,7 @@ namespace authentication {
class BaseResult {
public:
BaseResult(int status, std::string error,
- std::shared_ptr json_document = nullptr);
+ std::shared_ptr json_document = nullptr);
virtual ~BaseResult();
/**
diff --git a/olp-cpp-sdk-authentication/src/ResponseFromJsonBuilder.h b/olp-cpp-sdk-authentication/src/ResponseFromJsonBuilder.h
index 8d4ee37d5..49764d7ca 100644
--- a/olp-cpp-sdk-authentication/src/ResponseFromJsonBuilder.h
+++ b/olp-cpp-sdk-authentication/src/ResponseFromJsonBuilder.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2021 HERE Europe B.V.
+ * Copyright (C) 2020-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,7 +35,8 @@ struct Identity {
template
class ResponseFromJsonBuilder {
- using JsonValue = rapidjson::Document::ValueType;
+ using JsonDoc = boost::json::object;
+ using JsonValue = boost::json::value;
public:
template
@@ -46,16 +47,16 @@ class ResponseFromJsonBuilder {
const std::string kLogTag = "ResponseFromJsonBuilder";
public:
- explicit BuilderHelper(const JsonValue& json_value) : json_{json_value} {}
+ explicit BuilderHelper(const JsonDoc& json_value) : json_{json_value} {}
template
BuilderHelper& Value(const char* name, void (TargetType::*set_fn)(ArgType),
Projection projection = {}) {
using CompatibleType = decltype(GetCompatibleType());
fields_.emplace(name, [=](TargetType& target_obj,
- const JsonValue& value) {
- if (value.Is()) {
- (target_obj.*set_fn)(projection(value.Get()));
+ const JsonValue& json_value) {
+ if (auto value = If(json_value)) {
+ (target_obj.*set_fn)(projection(*value));
} else {
OLP_SDK_LOG_WARNING_F(kLogTag, "Wrong type, response=%s, field=%s",
kTargetTypeName.c_str(), name);
@@ -71,13 +72,13 @@ class ResponseFromJsonBuilder {
decltype(GetCompatibleType());
fields_.emplace(name, [=](TargetType& target_obj,
const JsonValue& value) {
- if (value.IsArray()) {
- const auto& array = value.GetArray();
+ if (value.is_array()) {
+ const auto& array = value.get_array();
ArrayType array_result;
- array_result.reserve(array.Size());
+ array_result.reserve(array.size());
for (const auto& element : array) {
- if (element.Is()) {
- array_result.push_back(element.Get());
+ if (auto element_value = If(element)) {
+ array_result.push_back(*element_value);
}
}
(target_obj.*set_fn)(std::move(array_result));
@@ -92,12 +93,12 @@ class ResponseFromJsonBuilder {
TargetType Finish() {
TargetType result;
- auto it = json_.MemberBegin();
- auto it_end = json_.MemberEnd();
+ auto it = json_.cbegin();
+ auto it_end = json_.cend();
for (; it != it_end; ++it) {
- auto find_it = fields_.find(std::string{it->name.GetString()});
+ auto find_it = fields_.find(std::string{it->key_c_str()});
if (find_it != fields_.end()) {
- find_it->second(result, it->value);
+ find_it->second(result, it->value());
// erasing already processed value
fields_.erase(find_it);
continue;
@@ -105,7 +106,7 @@ class ResponseFromJsonBuilder {
OLP_SDK_LOG_WARNING_F(kLogTag,
"Unexpected value, response=%s, field=%s",
- kTargetTypeName.c_str(), it->name.GetString());
+ kTargetTypeName.c_str(), it->key_c_str());
}
// in the ideal scenario all fields should be processed
@@ -133,11 +134,39 @@ class ResponseFromJsonBuilder {
std::is_same::value>::type>
int64_t GetCompatibleType();
+ template ::value>::type>
+ const bool* If(const JsonValue& value) {
+ return value.if_bool();
+ }
+
+ template ::value ||
+ std::is_same::value>::type>
+ const int64_t* If(const JsonValue& value) {
+ return value.if_int64();
+ }
+
+ template ::value>::type>
+ const uint64_t* If(const JsonValue& value) {
+ return value.if_uint64();
+ }
+
+ template ::value>::type>
+ boost::optional If(const JsonValue& value) {
+ if (auto* str = value.if_string()) {
+ return str->c_str();
+ }
+ return nullptr;
+ }
+
using Fields =
std::unordered_map>;
- const JsonValue& json_;
+ const JsonDoc& json_;
Fields fields_;
};
diff --git a/olp-cpp-sdk-authentication/src/SignInResultImpl.cpp b/olp-cpp-sdk-authentication/src/SignInResultImpl.cpp
index da162ab2c..e3f614130 100644
--- a/olp-cpp-sdk-authentication/src/SignInResultImpl.cpp
+++ b/olp-cpp-sdk-authentication/src/SignInResultImpl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2021 HERE Europe B.V.
+ * Copyright (C) 2019-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,14 +37,14 @@ SignInResultImpl::SignInResultImpl() noexcept
SignInResultImpl::SignInResultImpl(
int status, std::string error,
- std::shared_ptr json_document) noexcept
+ std::shared_ptr json_document) noexcept
: BaseResult(status, std::move(error), json_document),
expiry_time_(),
expires_in_() {
is_valid_ = this->BaseResult::IsValid() &&
- json_document->HasMember(Constants::ACCESS_TOKEN) &&
- json_document->HasMember(kTokenType) &&
- json_document->HasMember(Constants::EXPIRES_IN);
+ json_document->contains(Constants::ACCESS_TOKEN) &&
+ json_document->contains(kTokenType) &&
+ json_document->contains(Constants::EXPIRES_IN);
// Extra response data if no errors reported
if (!HasError()) {
@@ -52,22 +52,25 @@ SignInResultImpl::SignInResultImpl(
status_ = http::HttpStatusCode::SERVICE_UNAVAILABLE;
error_.message = Constants::ERROR_HTTP_SERVICE_UNAVAILABLE;
} else {
- if (json_document->HasMember(Constants::ACCESS_TOKEN))
- access_token_ = (*json_document)[Constants::ACCESS_TOKEN].GetString();
- if (json_document->HasMember(kTokenType))
- token_type_ = (*json_document)[kTokenType].GetString();
- if (json_document->HasMember(Constants::REFRESH_TOKEN))
- refresh_token_ = (*json_document)[Constants::REFRESH_TOKEN].GetString();
- if (json_document->HasMember(Constants::EXPIRES_IN)) {
- expiry_time_ = std::time(nullptr) +
- (*json_document)[Constants::EXPIRES_IN].GetUint();
+ if (json_document->contains(Constants::ACCESS_TOKEN))
+ access_token_ =
+ (*json_document)[Constants::ACCESS_TOKEN].get_string().c_str();
+ if (json_document->contains(kTokenType))
+ token_type_ = (*json_document)[kTokenType].get_string().c_str();
+ if (json_document->contains(Constants::REFRESH_TOKEN))
+ refresh_token_ =
+ (*json_document)[Constants::REFRESH_TOKEN].get_string().c_str();
+ if (json_document->contains(Constants::EXPIRES_IN)) {
+ expiry_time_ =
+ std::time(nullptr) +
+ (*json_document)[Constants::EXPIRES_IN].to_number();
expires_in_ = std::chrono::seconds(
- (*json_document)[Constants::EXPIRES_IN].GetUint());
+ (*json_document)[Constants::EXPIRES_IN].to_number());
}
- if (json_document->HasMember(kUserId))
- user_identifier_ = (*json_document)[kUserId].GetString();
- if (json_document->HasMember(kScope))
- scope_ = (*json_document)[kScope].GetString();
+ if (json_document->contains(kUserId))
+ user_identifier_ = (*json_document)[kUserId].get_string().c_str();
+ if (json_document->contains(kScope))
+ scope_ = (*json_document)[kScope].get_string().c_str();
}
}
}
diff --git a/olp-cpp-sdk-authentication/src/SignInResultImpl.h b/olp-cpp-sdk-authentication/src/SignInResultImpl.h
index 1712f443f..0ad6e02e6 100644
--- a/olp-cpp-sdk-authentication/src/SignInResultImpl.h
+++ b/olp-cpp-sdk-authentication/src/SignInResultImpl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2021 HERE Europe B.V.
+ * Copyright (C) 2019-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,10 +19,10 @@
#pragma once
+#include
#include
#include
#include
-#include
#include "BaseResult.h"
@@ -34,7 +34,7 @@ class SignInResultImpl : public BaseResult {
SignInResultImpl(
int status, std::string error,
- std::shared_ptr json_document = nullptr) noexcept;
+ std::shared_ptr json_document = nullptr) noexcept;
~SignInResultImpl() override;
@@ -65,7 +65,7 @@ class SignInResultImpl : public BaseResult {
*/
time_t GetExpiryTime() const;
- /**
+ /**
* @brief Gets the access token expiry time in seconds.
* @return Duration for which token stays valid.
*/
diff --git a/olp-cpp-sdk-authentication/src/SignInUserResultImpl.cpp b/olp-cpp-sdk-authentication/src/SignInUserResultImpl.cpp
index 36530f40d..c15941619 100644
--- a/olp-cpp-sdk-authentication/src/SignInUserResultImpl.cpp
+++ b/olp-cpp-sdk-authentication/src/SignInUserResultImpl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2021 HERE Europe B.V.
+ * Copyright (C) 2019-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,23 +40,24 @@ SignInUserResultImpl::SignInUserResultImpl() noexcept
SignInUserResultImpl::SignInUserResultImpl(
int status, std::string error,
- std::shared_ptr json_document) noexcept
+ std::shared_ptr json_document) noexcept
: SignInResultImpl(status, std::move(error), json_document) {
if (BaseResult::IsValid()) {
- if (json_document->HasMember(kTermsReacceptanceToken))
+ if (json_document->contains(kTermsReacceptanceToken))
term_acceptance_token_ =
- (*json_document)[kTermsReacceptanceToken].GetString();
- if (json_document->HasMember(kTermsUrls)) {
- rapidjson::Document::Object obj =
- (*json_document)[kTermsUrls].GetObject();
- if (obj.HasMember(kTermsOfServiceUrl))
- terms_of_service_url_ = obj[kTermsOfServiceUrl].GetString();
- if (obj.HasMember(kTermsOfServiceUrlJson))
- terms_of_service_url_json_ = obj[kTermsOfServiceUrlJson].GetString();
- if (obj.HasMember(kPrivatePolicyUrl))
- private_policy_url_ = obj[kPrivatePolicyUrl].GetString();
- if (obj.HasMember(kPrivatePolicyUrlJson))
- private_policy_url_json_ = obj[kPrivatePolicyUrlJson].GetString();
+ (*json_document)[kTermsReacceptanceToken].get_string().c_str();
+ if (json_document->contains(kTermsUrls)) {
+ auto& obj = (*json_document)[kTermsUrls].get_object();
+ if (obj.contains(kTermsOfServiceUrl))
+ terms_of_service_url_ = obj[kTermsOfServiceUrl].get_string().c_str();
+ if (obj.contains(kTermsOfServiceUrlJson))
+ terms_of_service_url_json_ =
+ obj[kTermsOfServiceUrlJson].get_string().c_str();
+ if (obj.contains(kPrivatePolicyUrl))
+ private_policy_url_ = obj[kPrivatePolicyUrl].get_string().c_str();
+ if (obj.contains(kPrivatePolicyUrlJson))
+ private_policy_url_json_ =
+ obj[kPrivatePolicyUrlJson].get_string().c_str();
}
}
}
diff --git a/olp-cpp-sdk-authentication/src/SignInUserResultImpl.h b/olp-cpp-sdk-authentication/src/SignInUserResultImpl.h
index c6fd5218c..020a7d106 100644
--- a/olp-cpp-sdk-authentication/src/SignInUserResultImpl.h
+++ b/olp-cpp-sdk-authentication/src/SignInUserResultImpl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2021 HERE Europe B.V.
+ * Copyright (C) 2019-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ class SignInUserResultImpl : public SignInResultImpl {
SignInUserResultImpl(
int status, std::string error,
- std::shared_ptr json_document = nullptr) noexcept;
+ std::shared_ptr json_document = nullptr) noexcept;
~SignInUserResultImpl() override;
diff --git a/olp-cpp-sdk-authentication/src/SignOutResultImpl.cpp b/olp-cpp-sdk-authentication/src/SignOutResultImpl.cpp
index d223919f4..447471d06 100644
--- a/olp-cpp-sdk-authentication/src/SignOutResultImpl.cpp
+++ b/olp-cpp-sdk-authentication/src/SignOutResultImpl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2021 HERE Europe B.V.
+ * Copyright (C) 2019-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ SignOutResultImpl::SignOutResultImpl() noexcept
SignOutResultImpl::SignOutResultImpl(
int status, std::string error,
- std::shared_ptr json_document) noexcept
+ std::shared_ptr json_document) noexcept
: BaseResult(status, std::move(error), json_document) {}
SignOutResultImpl::~SignOutResultImpl() = default;
diff --git a/olp-cpp-sdk-authentication/src/SignOutResultImpl.h b/olp-cpp-sdk-authentication/src/SignOutResultImpl.h
index 8c13229db..6a7c8baf3 100644
--- a/olp-cpp-sdk-authentication/src/SignOutResultImpl.h
+++ b/olp-cpp-sdk-authentication/src/SignOutResultImpl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 HERE Europe B.V.
+ * Copyright (C) 2019-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ class SignOutResultImpl : public BaseResult {
SignOutResultImpl(
int status, std::string error,
- std::shared_ptr json_document = nullptr) noexcept;
+ std::shared_ptr json_document = nullptr) noexcept;
~SignOutResultImpl() override;
};
diff --git a/olp-cpp-sdk-authentication/src/SignUpResultImpl.cpp b/olp-cpp-sdk-authentication/src/SignUpResultImpl.cpp
index 27ea17db3..4fb5fadb3 100644
--- a/olp-cpp-sdk-authentication/src/SignUpResultImpl.cpp
+++ b/olp-cpp-sdk-authentication/src/SignUpResultImpl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2021 HERE Europe B.V.
+ * Copyright (C) 2019-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,11 +35,11 @@ SignUpResultImpl::SignUpResultImpl() noexcept
SignUpResultImpl::SignUpResultImpl(
int status, std::string error,
- std::shared_ptr json_document) noexcept
+ std::shared_ptr json_document) noexcept
: BaseResult(status, std::move(error), json_document) {
if (BaseResult::IsValid()) {
- if (json_document->HasMember(kUserId))
- user_identifier_ = (*json_document)[kUserId].GetString();
+ if (json_document->contains(kUserId))
+ user_identifier_ = (*json_document)[kUserId].get_string().c_str();
}
}
diff --git a/olp-cpp-sdk-authentication/src/SignUpResultImpl.h b/olp-cpp-sdk-authentication/src/SignUpResultImpl.h
index 7434d8e0a..9eca11bbd 100644
--- a/olp-cpp-sdk-authentication/src/SignUpResultImpl.h
+++ b/olp-cpp-sdk-authentication/src/SignUpResultImpl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2021 HERE Europe B.V.
+ * Copyright (C) 2019-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@
#include
#include
-#include
+#include
#include "BaseResult.h"
@@ -35,7 +35,7 @@ class SignUpResultImpl : public BaseResult {
SignUpResultImpl(
int status, std::string error,
- std::shared_ptr json_document = nullptr) noexcept;
+ std::shared_ptr json_document = nullptr) noexcept;
~SignUpResultImpl() override;
diff --git a/olp-cpp-sdk-authentication/src/TokenEndpointImpl.cpp b/olp-cpp-sdk-authentication/src/TokenEndpointImpl.cpp
index 5e38439d9..148d761c6 100644
--- a/olp-cpp-sdk-authentication/src/TokenEndpointImpl.cpp
+++ b/olp-cpp-sdk-authentication/src/TokenEndpointImpl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021-2024 HERE Europe B.V.
+ * Copyright (C) 2021-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,10 +29,9 @@
#include
#include
#include
-#include
-#include
-#include
-#include
+#include
+#include
+#include
#include
#include
#include "AuthenticationClientUtils.h"
@@ -102,22 +101,24 @@ void RetryDelay(const client::RetrySettings& retry_settings, size_t retry) {
}
TimeResponse ParseTimeResponse(const std::string& payload) {
- rapidjson::Document document;
- document.Parse(payload.c_str());
+ boost::json::error_code ec;
+ auto document = boost::json::parse(payload, ec);
- if (!document.IsObject()) {
+ if (!document.is_object()) {
return client::ApiError(client::ErrorCode::InternalFailure,
"JSON document root is not an Object type");
}
- const auto timestamp_it = document.FindMember("timestamp");
- if (timestamp_it == document.MemberEnd() || !timestamp_it->value.IsUint()) {
+ const auto timestamp_it = document.as_object().find("timestamp");
+ if (timestamp_it == document.as_object().end() ||
+ (!timestamp_it->value().is_uint64() &&
+ !timestamp_it->value().is_int64())) {
return client::ApiError(
client::ErrorCode::InternalFailure,
"JSON document must contain timestamp integer field");
}
- return timestamp_it->value.GetUint();
+ return timestamp_it->value().to_number();
}
std::string GenerateUid() {
@@ -130,28 +131,22 @@ std::string GenerateUid() {
client::OlpClient::RequestBodyType GenerateClientBody(
const TokenRequest& token_request,
const boost::optional& scope) {
- rapidjson::StringBuffer data;
- rapidjson::Writer writer(data);
- writer.StartObject();
+ boost::json::object object;
- writer.Key(kGrantType);
- writer.String(kClientGrantType);
+ object[kGrantType] = kClientGrantType;
auto expires_in =
static_cast(token_request.GetExpiresIn().count());
if (expires_in > 0) {
- writer.Key(Constants::EXPIRES_IN);
- writer.Uint(expires_in);
+ object[Constants::EXPIRES_IN] = expires_in;
}
if (scope) {
- writer.Key(kScope);
- writer.String(scope.get().c_str());
+ object[kScope] = scope.get();
}
- writer.EndObject();
- auto content = data.GetString();
- return std::make_shared(content, content + data.GetSize());
+ auto content = boost::json::serialize(object);
+ return std::make_shared(content.begin(), content.end());
}
TimeResponse GetTimeFromServer(client::CancellationContext& context,
@@ -333,11 +328,13 @@ SignInResponse TokenEndpointImpl::SignInClient(
SignInResult TokenEndpointImpl::ParseAuthResponse(
int status, std::stringstream& auth_response) {
- auto document = std::make_shared();
- rapidjson::IStreamWrapper stream(auth_response);
- document->ParseStream(stream);
+ boost::json::error_code ec;
+ auto document = boost::json::parse(auth_response, ec);
return std::make_shared(
- status, http::HttpErrorToString(status), document);
+ status, http::HttpErrorToString(status),
+ ec.failed() || !document.is_object()
+ ? nullptr
+ : std::make_shared(document.as_object()));
}
client::HttpResponse TokenEndpointImpl::CallAuth(
diff --git a/olp-cpp-sdk-core/CMakeLists.txt b/olp-cpp-sdk-core/CMakeLists.txt
index 8264461dc..195f170c5 100644
--- a/olp-cpp-sdk-core/CMakeLists.txt
+++ b/olp-cpp-sdk-core/CMakeLists.txt
@@ -19,7 +19,6 @@
project(olp-cpp-sdk-core VERSION 1.21.0)
set(DESCRIPTION "Core network and utility library for the HERE OLP SDK C++")
-find_package(RapidJSON 1.1.0 REQUIRED)
find_package(Boost REQUIRED)
find_package(Threads REQUIRED)
@@ -350,6 +349,7 @@ endif()
set(OLP_SDK_UTILS_SOURCES
./src/utils/Base64.cpp
./src/utils/BoostExceptionHandle.cpp
+ ./src/utils/BoostJsonSrc.cpp
./src/utils/Credentials.cpp
./src/utils/Dir.cpp
./src/utils/Thread.cpp
@@ -436,14 +436,15 @@ if (OLP_SDK_NO_EXCEPTION AND NOT OLP_SDK_BOOST_THROW_EXCEPTION_EXTERNAL)
PRIVATE OLP_SDK_BOOST_THROW_EXCEPTION=1)
endif()
+target_compile_definitions(${PROJECT_NAME}
+ PRIVATE BOOST_ALL_NO_LIB)
+
target_include_directories(${PROJECT_NAME} PUBLIC
$
$
$
$
- $
-
$)
if (ANDROID)
diff --git a/olp-cpp-sdk-core/include/olp/core/generated/parser/JsonParser.h b/olp-cpp-sdk-core/include/olp/core/generated/parser/JsonParser.h
index d5127e61e..b373e4d45 100644
--- a/olp-cpp-sdk-core/include/olp/core/generated/parser/JsonParser.h
+++ b/olp-cpp-sdk-core/include/olp/core/generated/parser/JsonParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2024 HERE Europe B.V.
+ * Copyright (C) 2019-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,8 +24,7 @@
#include
#include
-#include
-#include
+#include
#include "ParserWrapper.h"
@@ -33,11 +32,11 @@ namespace olp {
namespace parser {
template
inline T parse(const std::string& json) {
- rapidjson::Document doc;
- doc.Parse(json.c_str());
+ boost::json::error_code ec;
+ auto value = boost::json::parse(json, ec);
T result{};
- if (doc.IsObject() || doc.IsArray()) {
- from_json(doc, result);
+ if (value.is_object() || value.is_array()) {
+ from_json(value, result);
}
return result;
}
@@ -45,12 +44,11 @@ inline T parse(const std::string& json) {
template
inline T parse(std::stringstream& json_stream, bool& res) {
res = false;
- rapidjson::Document doc;
- rapidjson::IStreamWrapper stream(json_stream);
- doc.ParseStream(stream);
+ boost::json::error_code ec;
+ auto value = boost::json::parse(json_stream, ec);
T result{};
- if (doc.IsObject() || doc.IsArray()) {
- from_json(doc, result);
+ if (value.is_object() || value.is_array()) {
+ from_json(value, result);
res = true;
}
return result;
@@ -64,11 +62,13 @@ inline T parse(std::stringstream& json_stream) {
template
inline T parse(const std::shared_ptr>& json_bytes) {
- rapidjson::Document doc;
- doc.Parse(reinterpret_cast(json_bytes->data()), json_bytes->size());
+ boost::json::string_view json(reinterpret_cast(json_bytes->data()),
+ json_bytes->size());
+ boost::json::error_code ec;
+ auto value = boost::json::parse(json, ec);
T result{};
- if (doc.IsObject() || doc.IsArray()) {
- from_json(doc, result);
+ if (value.is_object() || value.is_array()) {
+ from_json(value, result);
}
return result;
}
diff --git a/olp-cpp-sdk-core/include/olp/core/generated/parser/ParserWrapper.h b/olp-cpp-sdk-core/include/olp/core/generated/parser/ParserWrapper.h
index 0a17b7bab..540e5110a 100644
--- a/olp-cpp-sdk-core/include/olp/core/generated/parser/ParserWrapper.h
+++ b/olp-cpp-sdk-core/include/olp/core/generated/parser/ParserWrapper.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2023 HERE Europe B.V.
+ * Copyright (C) 2019-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,72 +24,74 @@
#include
#include
-#include
+#include
#include
namespace olp {
namespace parser {
-inline void from_json(const rapidjson::Value& value, std::string& x) {
- x = value.GetString();
+inline void from_json(const boost::json::value& value, std::string& x) {
+ const auto& str = value.get_string();
+ x.assign(str.begin(), str.end());
}
-inline void from_json(const rapidjson::Value& value, int32_t& x) {
- x = value.GetInt();
+inline void from_json(const boost::json::value& value, int32_t& x) {
+ x = static_cast(value.to_number());
}
-inline void from_json(const rapidjson::Value& value, int64_t& x) {
- x = value.GetInt64();
+inline void from_json(const boost::json::value& value, int64_t& x) {
+ x = value.to_number();
}
-inline void from_json(const rapidjson::Value& value, double& x) {
- x = value.GetDouble();
+inline void from_json(const boost::json::value& value, double& x) {
+ x = value.to_number();
}
-inline void from_json(const rapidjson::Value& value, bool& x) {
- x = value.GetBool();
+inline void from_json(const boost::json::value& value, bool& x) {
+ x = value.get_bool();
}
-inline void from_json(const rapidjson::Value& value,
+inline void from_json(const boost::json::value& value,
std::shared_ptr>& x) {
- std::string s = value.GetString();
+ const auto& s = value.get_string();
x = std::make_shared>(s.begin(), s.end());
}
template
-inline void from_json(const rapidjson::Value& value, boost::optional& x) {
+inline void from_json(const boost::json::value& value, boost::optional& x) {
T result = T();
from_json(value, result);
x = result;
}
template
-inline void from_json(const rapidjson::Value& value,
+inline void from_json(const boost::json::value& value,
std::map& results) {
- for (rapidjson::Value::ConstMemberIterator itr = value.MemberBegin();
- itr != value.MemberEnd(); ++itr) {
- std::string key;
- from_json(itr->name, key);
- from_json(itr->value, results[key]);
+ const auto& object = value.get_object();
+ for (const auto& object_value : object) {
+ std::string key = object_value.key();
+ from_json(object_value.value(), results[key]);
}
}
template
-inline void from_json(const rapidjson::Value& value, std::vector& results) {
- for (rapidjson::Value::ConstValueIterator itr = value.Begin();
- itr != value.End(); ++itr) {
+inline void from_json(const boost::json::value& value,
+ std::vector& results) {
+ const auto& array = value.get_array();
+ for (const auto& array_value : array) {
T result;
- from_json(*itr, result);
+ from_json(array_value, result);
results.emplace_back(std::move(result));
}
}
template
-inline T parse(const rapidjson::Value& value, const std::string& name) {
+inline T parse(const boost::json::value& value, const std::string& name) {
T result = T();
- rapidjson::Value::ConstMemberIterator itr = value.FindMember(name.c_str());
- if (itr != value.MemberEnd()) {
- from_json(itr->value, result);
+ const auto& object = value.get_object();
+ auto itr = object.find(name);
+ if (itr != object.end()) {
+ from_json(itr->value(), result);
}
return result;
}
diff --git a/olp-cpp-sdk-core/include/olp/core/generated/serializer/SerializerWrapper.h b/olp-cpp-sdk-core/include/olp/core/generated/serializer/SerializerWrapper.h
index 5bec32f3e..0f8cf32d7 100644
--- a/olp-cpp-sdk-core/include/olp/core/generated/serializer/SerializerWrapper.h
+++ b/olp-cpp-sdk-core/include/olp/core/generated/serializer/SerializerWrapper.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2021 HERE Europe B.V.
+ * Copyright (C) 2019-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,91 +22,79 @@
#include