File tree 2 files changed +8
-2
lines changed 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ class JSON_API FastWriter : public Writer {
54
54
*/
55
55
void dropNullPlaceholders ();
56
56
57
+ void omitEndingLineFeed ();
58
+
57
59
public: // overridden from Writer
58
60
virtual std::string write (const Value &root);
59
61
@@ -63,6 +65,7 @@ class JSON_API FastWriter : public Writer {
63
65
std::string document_;
64
66
bool yamlCompatiblityEnabled_;
65
67
bool dropNullPlaceholders_;
68
+ bool omitEndingLineFeed_;
66
69
};
67
70
68
71
/* * \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
Original file line number Diff line number Diff line change @@ -180,16 +180,19 @@ Writer::~Writer() {}
180
180
// //////////////////////////////////////////////////////////////////
181
181
182
182
FastWriter::FastWriter ()
183
- : yamlCompatiblityEnabled_(false ), dropNullPlaceholders_(false ) {}
183
+ : yamlCompatiblityEnabled_(false ), dropNullPlaceholders_(false ), omitEndingLineFeed_( false ) {}
184
184
185
185
void FastWriter::enableYAMLCompatibility () { yamlCompatiblityEnabled_ = true ; }
186
186
187
187
void FastWriter::dropNullPlaceholders () { dropNullPlaceholders_ = true ; }
188
188
189
+ void FastWriter::omitEndingLineFeed () { omitEndingLineFeed_ = true ; }
190
+
189
191
std::string FastWriter::write (const Value &root) {
190
192
document_ = " " ;
191
193
writeValue (root);
192
- document_ += " \n " ;
194
+ if (!omitEndingLineFeed_)
195
+ document_ += " \n " ;
193
196
return document_;
194
197
}
195
198
You can’t perform that action at this time.
0 commit comments