Go to the documentation of this file.
6 #ifndef JSON_WRITER_H_INCLUDED
7 #define JSON_WRITER_H_INCLUDED
9 #if !defined(JSON_IS_AMALGAMATION)
11 #endif // if !defined(JSON_IS_AMALGAMATION)
18 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) && defined(_MSC_VER)
20 #pragma warning(disable : 4251)
21 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
164 #if defined(_MSC_VER)
165 #pragma warning(push)
166 #pragma warning(disable : 4996) // Deriving from deprecated class
172 ~FastWriter()
override =
default;
174 void enableYAMLCompatibility();
181 void dropNullPlaceholders();
183 void omitEndingLineFeed();
186 String write(
const Value& root)
override;
189 void writeValue(
const Value& value);
192 bool yamlCompatibilityEnabled_{
false};
193 bool dropNullPlaceholders_{
false};
194 bool omitEndingLineFeed_{
false};
196 #if defined(_MSC_VER)
224 #if defined(_MSC_VER)
225 #pragma warning(push)
226 #pragma warning(disable : 4996) // Deriving from deprecated class
229 StyledWriter :
public Writer {
232 ~StyledWriter()
override =
default;
239 String write(
const Value& root)
override;
242 void writeValue(
const Value& value);
243 void writeArrayValue(
const Value& value);
244 bool isMultilineArray(
const Value& value);
245 void pushValue(
const String& value);
247 void writeWithIndent(
const String& value);
250 void writeCommentBeforeValue(
const Value& root);
251 void writeCommentAfterValueOnSameLine(
const Value& root);
252 static bool hasCommentForValue(
const Value& value);
255 typedef std::vector<String> ChildValues;
257 ChildValues childValues_;
260 unsigned int rightMargin_{74};
261 unsigned int indentSize_{3};
262 bool addChildValues_{
false};
264 #if defined(_MSC_VER)
293 #if defined(_MSC_VER)
294 #pragma warning(push)
295 #pragma warning(disable : 4996) // Deriving from deprecated class
303 StyledStreamWriter(
String indentation =
"\t");
304 ~StyledStreamWriter() =
default;
316 void writeValue(
const Value& value);
317 void writeArrayValue(
const Value& value);
318 bool isMultilineArray(
const Value& value);
319 void pushValue(
const String& value);
321 void writeWithIndent(
const String& value);
324 void writeCommentBeforeValue(
const Value& root);
325 void writeCommentAfterValueOnSameLine(
const Value& root);
326 static bool hasCommentForValue(
const Value& value);
329 typedef std::vector<String> ChildValues;
331 ChildValues childValues_;
334 unsigned int rightMargin_{74};
336 bool addChildValues_ : 1;
339 #if defined(_MSC_VER)
343 #if defined(JSON_HAS_INT64)
346 #endif // if defined(JSON_HAS_INT64)
363 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
365 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
367 #endif // JSON_WRITER_H_INCLUDED
static constexpr UInt defaultRealPrecision
Default precision for real value for string representation.
String valueToString(Int value)
we set max number of significant digits in string
A simple abstract factory.
OStream & operator<<(OStream &, const Value &root)
Output using the StyledStreamWriter.
PrecisionType
Type of precision for formatting of real values.
Json::Value settings_
Configuration of this builder.
#define JSONCPP_DEPRECATED(message)
JSON (JavaScript Object Notation).
#define JSON_API
If defined, indicates that the source file is amalgamated to prevent private header inclusion.
std::basic_string< char, std::char_traits< char >, Allocator< char > > String
String valueToQuotedString(const char *value)
String writeString(StreamWriter::Factory const &factory, Value const &root)
Write into stringstream, then return string, for convenience.
Build a StreamWriter implementation.