6 #ifndef JSON_WRITER_H_INCLUDED
7 #define JSON_WRITER_H_INCLUDED
9 #if !defined(JSON_IS_AMALGAMATION)
18 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) && defined(_MSC_VER)
20 #pragma warning(disable : 4251)
44 JSONCPP_OSTREAM* sout_;
54 virtual int write(
Value const& root, JSONCPP_OSTREAM* sout) = 0;
130 Value& operator[](JSONCPP_STRING key);
147 virtual JSONCPP_STRING write(
const Value& root) = 0;
159 #if defined(_MSC_VER)
160 #pragma warning(push)
161 #pragma warning(disable:4996)
166 ~FastWriter() JSONCPP_OVERRIDE {}
168 void enableYAMLCompatibility();
175 void dropNullPlaceholders();
177 void omitEndingLineFeed();
180 JSONCPP_STRING write(
const Value& root) JSONCPP_OVERRIDE;
183 void writeValue(
const Value& value);
185 JSONCPP_STRING document_;
186 bool yamlCompatibilityEnabled_;
187 bool dropNullPlaceholders_;
188 bool omitEndingLineFeed_;
190 #if defined(_MSC_VER)
218 #if defined(_MSC_VER)
219 #pragma warning(push)
220 #pragma warning(disable:4996)
222 class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API StyledWriter :
public Writer {
225 ~StyledWriter() JSONCPP_OVERRIDE {}
232 JSONCPP_STRING write(
const Value& root) JSONCPP_OVERRIDE;
235 void writeValue(
const Value& value);
236 void writeArrayValue(
const Value& value);
237 bool isMultilineArray(
const Value& value);
238 void pushValue(
const JSONCPP_STRING& value);
240 void writeWithIndent(
const JSONCPP_STRING& value);
243 void writeCommentBeforeValue(
const Value& root);
244 void writeCommentAfterValueOnSameLine(
const Value& root);
245 bool hasCommentForValue(
const Value& value);
246 static JSONCPP_STRING normalizeEOL(
const JSONCPP_STRING& text);
248 typedef std::vector<JSONCPP_STRING> ChildValues;
250 ChildValues childValues_;
251 JSONCPP_STRING document_;
252 JSONCPP_STRING indentString_;
253 unsigned int rightMargin_;
254 unsigned int indentSize_;
255 bool addChildValues_;
257 #if defined(_MSC_VER)
286 #if defined(_MSC_VER)
287 #pragma warning(push)
288 #pragma warning(disable:4996)
290 class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API StyledStreamWriter {
295 StyledStreamWriter(JSONCPP_STRING indentation =
"\t");
296 ~StyledStreamWriter() {}
305 void write(JSONCPP_OSTREAM& out,
const Value& root);
308 void writeValue(
const Value& value);
309 void writeArrayValue(
const Value& value);
310 bool isMultilineArray(
const Value& value);
311 void pushValue(
const JSONCPP_STRING& value);
313 void writeWithIndent(
const JSONCPP_STRING& value);
316 void writeCommentBeforeValue(
const Value& root);
317 void writeCommentAfterValueOnSameLine(
const Value& root);
318 bool hasCommentForValue(
const Value& value);
319 static JSONCPP_STRING normalizeEOL(
const JSONCPP_STRING& text);
321 typedef std::vector<JSONCPP_STRING> ChildValues;
323 ChildValues childValues_;
324 JSONCPP_OSTREAM* document_;
325 JSONCPP_STRING indentString_;
326 unsigned int rightMargin_;
327 JSONCPP_STRING indentation_;
328 bool addChildValues_ : 1;
331 #if defined(_MSC_VER)
335 #if defined(JSON_HAS_INT64)
336 JSONCPP_STRING JSON_API valueToString(Int value);
337 JSONCPP_STRING JSON_API valueToString(UInt value);
339 JSONCPP_STRING JSON_API valueToString(LargestInt value);
340 JSONCPP_STRING JSON_API valueToString(LargestUInt value);
341 JSONCPP_STRING JSON_API valueToString(
double value);
342 JSONCPP_STRING JSON_API valueToString(
bool value);
343 JSONCPP_STRING JSON_API valueToQuotedString(
const char* value);
353 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
A simple abstract factory.
virtual StreamWriter * newStreamWriter() const =0
Allocate a CharReader via operator new().
Build a StreamWriter implementation.
Json::Value settings_
Configuration of this builder.
virtual int write(Value const &root, JSONCPP_OSTREAM *sout)=0
Write Value into document as configured in sub-class.
JSON (JavaScript Object Notation).
class JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead") JSON_API Reader
Unserialize a JSON document into a Value.
JSON_API JSONCPP_OSTREAM & operator<<(JSONCPP_OSTREAM &, const Value &root)
Output using the StyledStreamWriter.
JSONCPP_STRING JSON_API writeString(StreamWriter::Factory const &factory, Value const &root)
Write into stringstream, then return string, for convenience.