summaryrefslogtreecommitdiff
path: root/src/components/formatters/include/formatters
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2020-02-17 13:05:54 -0500
committerJackLivio <jack@livio.io>2020-02-17 13:05:54 -0500
commit86dea8793023f986c7c10d7f9e5b7a932d89a49a (patch)
treebf44b0d5b6bf6b6c78dd2d0602b67f05ebe2a17c /src/components/formatters/include/formatters
parent4310b2dfd5e1078df0df53138a73d49d000c9c62 (diff)
parentece258838a44a5461d718c5eeae380ad11a3769b (diff)
downloadsdl_core-86dea8793023f986c7c10d7f9e5b7a932d89a49a.tar.gz
Merge remote-tracking branch 'origin/develop' into fix/3rd_party_build_issuesfix/3rd_party_build_issues
Diffstat (limited to 'src/components/formatters/include/formatters')
-rw-r--r--src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h7
-rw-r--r--src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h11
-rw-r--r--src/components/formatters/include/formatters/formatter_json_rpc.h9
3 files changed, 18 insertions, 9 deletions
diff --git a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h
index b1054100df..ef1bfa1acd 100644
--- a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h
+++ b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h
@@ -174,11 +174,14 @@ int32_t formatters::CFormatterJsonSDLRPCv1::fromString(
int32_t result = kSuccess;
try {
+ Json::CharReaderBuilder reader_builder;
+ const std::unique_ptr<Json::CharReader> reader(
+ reader_builder.newCharReader());
Json::Value root;
- Json::Reader reader;
+ const size_t json_len = str.length();
std::string type;
- if (false == reader.parse(str, root)) {
+ if (!reader->parse(str.c_str(), str.c_str() + json_len, &root, nullptr)) {
result = kParsingError | kMessageTypeNotFound | kFunctionIdNotFound |
kCorrelationIdNotFound;
}
diff --git a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h
index ab0289b293..416aabe777 100644
--- a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h
+++ b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h
@@ -151,13 +151,16 @@ inline bool CFormatterJsonSDLRPCv2::fromString(
bool result = true;
try {
+ Json::CharReaderBuilder reader_builder;
+ const std::unique_ptr<Json::CharReader> reader(
+ reader_builder.newCharReader());
Json::Value root;
- Json::Reader reader;
-
+ const size_t json_len = str.length();
namespace strings = ns_smart_device_link::ns_json_handler::strings;
- bool result = reader.parse(str, root);
+ const bool result =
+ reader->parse(str.c_str(), str.c_str() + json_len, &root, nullptr);
- if (true == result) {
+ if (result) {
out[strings::S_PARAMS][strings::S_MESSAGE_TYPE] = messageType;
out[strings::S_PARAMS][strings::S_FUNCTION_ID] = functionId;
out[strings::S_PARAMS][strings::S_PROTOCOL_TYPE] = 0;
diff --git a/src/components/formatters/include/formatters/formatter_json_rpc.h b/src/components/formatters/include/formatters/formatter_json_rpc.h
index 593c837877..d1c87fe587 100644
--- a/src/components/formatters/include/formatters/formatter_json_rpc.h
+++ b/src/components/formatters/include/formatters/formatter_json_rpc.h
@@ -278,11 +278,14 @@ int32_t FormatterJsonRpc::FromString(const std::string& str,
ns_smart_objects::SmartObject& out) {
int32_t result = kSuccess;
try {
- Json::Value root;
- Json::Reader reader;
namespace strings = ns_smart_device_link::ns_json_handler::strings;
+ Json::CharReaderBuilder reader_builder;
+ const std::unique_ptr<Json::CharReader> reader(
+ reader_builder.newCharReader());
+ Json::Value root;
+ const size_t json_len = str.length();
- if (false == reader.parse(str, root)) {
+ if (!reader->parse(str.c_str(), str.c_str() + json_len, &root, nullptr)) {
result = kParsingError | kMethodNotSpecified | kUnknownMethod |
kUnknownMessageType;
} else {