File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ class JSON_API FastWriter : public Writer {
5454 */
5555 void dropNullPlaceholders ();
5656
57+ void omitEndingLineFeed ();
58+
5759public: // overridden from Writer
5860 virtual std::string write (const Value &root);
5961
@@ -63,6 +65,7 @@ class JSON_API FastWriter : public Writer {
6365 std::string document_;
6466 bool yamlCompatiblityEnabled_;
6567 bool dropNullPlaceholders_;
68+ bool omitEndingLineFeed_;
6669};
6770
6871/* * \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() {}
180180// //////////////////////////////////////////////////////////////////
181181
182182FastWriter::FastWriter ()
183- : yamlCompatiblityEnabled_(false ), dropNullPlaceholders_(false ) {}
183+ : yamlCompatiblityEnabled_(false ), dropNullPlaceholders_(false ), omitEndingLineFeed_( false ) {}
184184
185185void FastWriter::enableYAMLCompatibility () { yamlCompatiblityEnabled_ = true ; }
186186
187187void FastWriter::dropNullPlaceholders () { dropNullPlaceholders_ = true ; }
188188
189+ void FastWriter::omitEndingLineFeed () { omitEndingLineFeed_ = true ; }
190+
189191std::string FastWriter::write (const Value &root) {
190192 document_ = " " ;
191193 writeValue (root);
192- document_ += " \n " ;
194+ if (!omitEndingLineFeed_)
195+ document_ += " \n " ;
193196 return document_;
194197}
195198
You can’t perform that action at this time.
0 commit comments