mirror of
https://github.com/Tencent/rapidjson.git
synced 2025-03-06 13:41:35 +01:00
Example uses std::string Writer overload if RAPIDJSON_HAS_STDSTRING set.
This commit is contained in:
parent
1a76879c12
commit
9d4f0296ff
@ -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_);
|
||||
|
Loading…
x
Reference in New Issue
Block a user