aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Instances/InstanceScriptData.cpp2
-rw-r--r--src/server/shared/JSON/ProtobufJSON.cpp16
2 files changed, 9 insertions, 9 deletions
diff --git a/src/server/game/Instances/InstanceScriptData.cpp b/src/server/game/Instances/InstanceScriptData.cpp
index 999442b129c..a1845026bb1 100644
--- a/src/server/game/Instances/InstanceScriptData.cpp
+++ b/src/server/game/Instances/InstanceScriptData.cpp
@@ -49,7 +49,7 @@ InstanceScriptDataReader::Result InstanceScriptDataReader::Load(char const* data
}
}
*/
- if (_doc.Parse(data).HasParseError())
+ if (_doc.Parse(data, strlen(data)).HasParseError())
{
TC_LOG_ERROR("scripts.data.load", "JSON parser error {} at {} while loading data for instance {} [{}-{} | {}-{}]",
rapidjson::GetParseError_En(_doc.GetParseError()), _doc.GetErrorOffset(),
diff --git a/src/server/shared/JSON/ProtobufJSON.cpp b/src/server/shared/JSON/ProtobufJSON.cpp
index a0fe9b3a68f..1949f067eb9 100644
--- a/src/server/shared/JSON/ProtobufJSON.cpp
+++ b/src/server/shared/JSON/ProtobufJSON.cpp
@@ -20,9 +20,8 @@
#include "Log.h"
#include "StringFormat.h"
#include <google/protobuf/message.h>
-#include <rapidjson/writer.h>
#include <rapidjson/reader.h>
-#include <rapidjson/stringbuffer.h>
+#include <rapidjson/writer.h>
#include <stack>
class Serializer
@@ -188,7 +187,7 @@ class Deserializer : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>, Dese
public:
bool ReadMessage(std::string const& json, google::protobuf::Message* message);
- bool Key(const Ch* str, rapidjson::SizeType length, bool copy);
+ bool Key(Ch const* str, rapidjson::SizeType length, bool copy);
bool Null();
bool Bool(bool b);
bool Int(int32 i);
@@ -196,7 +195,7 @@ public:
bool Int64(int64 i);
bool Uint64(uint64 i);
bool Double(double d);
- bool String(const Ch* str, rapidjson::SizeType length, bool copy);
+ bool String(Ch const* str, rapidjson::SizeType length, bool copy);
bool StartObject();
bool EndObject(rapidjson::SizeType memberCount);
bool StartArray();
@@ -215,18 +214,19 @@ private:
bool Deserializer::ReadMessage(std::string const& json, google::protobuf::Message* message)
{
- rapidjson::StringStream ss(json.c_str());
+ rapidjson::MemoryStream ms(json.data(), json.length());
+ rapidjson::EncodedInputStream<rapidjson::UTF8<>, rapidjson::MemoryStream> is(ms);
_objectState.push(message);
- rapidjson::ParseResult result = _reader.Parse(ss, *this);
+ rapidjson::ParseResult result = _reader.Parse(is, *this);
ASSERT(result.IsError() || (_objectState.empty() && _state.empty()));
return !result.IsError() && _errors.empty();
}
-bool Deserializer::Key(const Ch* str, rapidjson::SizeType /*length*/, bool /*copy*/)
+bool Deserializer::Key(Ch const* str, rapidjson::SizeType /*length*/, bool /*copy*/)
{
google::protobuf::FieldDescriptor const* field = _objectState.top()->GetDescriptor()->FindFieldByName(str);
if (!field)
@@ -338,7 +338,7 @@ bool Deserializer::Double(double d)
return true;
}
-bool Deserializer::String(const Ch* str, rapidjson::SizeType /*length*/, bool /*copy*/)
+bool Deserializer::String(Ch const* str, rapidjson::SizeType /*length*/, bool /*copy*/)
{
google::protobuf::FieldDescriptor const* field = _state.top();
google::protobuf::Message* message = _objectState.top();