diff options
Diffstat (limited to 'src/components/formatters/include')
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 { |