Commit 9d4f0296 authored by Drew Noakes's avatar Drew Noakes

Example uses std::string Writer overload if RAPIDJSON_HAS_STDSTRING set.

parent 1a76879c
......@@ -19,8 +19,11 @@ protected:
void Serialize(Writer& writer) const {
// This base class just write out name-value pairs, without wrapping within an object.
writer.String("name");
#ifdef RAPIDJSON_HAS_STDSTRING
writer.String(name_);
#else
writer.String(name_.c_str(), (SizeType)name_.length()); // Supplying length of string is faster.
#endif
writer.String("age");
writer.Uint(age_);
}
......@@ -42,7 +45,11 @@ public:
writer.StartObject();
writer.String("school");
#ifdef RAPIDJSON_HAS_STDSTRING
writer.String(school_);
#else
writer.String(school_.c_str(), (SizeType)school_.length());
#endif
writer.String("GPA");
writer.Double(GPA_);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment