ADTF  3.18.2
StreamWriterBuilder

Build a StreamWriter implementation. More...

Inheritance diagram for StreamWriterBuilder:
[legend]

Public Member Functions

StreamWriternewStreamWriter () const JSONCPP_OVERRIDE
 
bool validate (Json::Value *invalid) const
 
Valueoperator[] (JSONCPP_STRING key)
 A simple way to update a specific setting.
 

Static Public Member Functions

static void setDefaults (Json::Value *settings)
 Called by ctor, but you can use this to reset settings_. More...
 

Public Attributes

Json::Value settings_
 Configuration of this builder. More...
 

Detailed Description

Build a StreamWriter implementation.

Usage:

using namespace Json;
Value value = ...;
StreamWriterBuilder builder;
builder["commentStyle"] = "None";
builder["indentation"] = " "; // or whatever you like
std::unique_ptr<Json::StreamWriter> writer(
builder.newStreamWriter());
writer->write(value, &std::cout);
std::cout << std::endl; // add lf and flush
JSON (JavaScript Object Notation).
Definition: allocator.h:14

Definition at line 89 of file workspace/conan/dev_essential/1.3.3/dw/stable/package/37682420cd166e229516a41c8d6a139a0b13e1e1/include/json/writer.h.

Member Function Documentation

◆ newStreamWriter()

StreamWriter* newStreamWriter ( ) const
virtual
Exceptions
std::exceptionif something goes wrong (e.g. invalid settings)

Implements StreamWriter::Factory.

◆ setDefaults()

static void setDefaults ( Json::Value settings)
static

Called by ctor, but you can use this to reset settings_.

Precondition
'settings' != NULL (but Json::null is fine)
Remarks
Defaults:

◆ validate()

bool validate ( Json::Value invalid) const
Returns
true if 'settings' are legal and consistent; otherwise, indicate bad settings via 'invalid'.

Member Data Documentation

◆ settings_

Json::Value settings_

Configuration of this builder.

Available settings (case-sensitive):

  • "commentStyle": "None" or "All"
  • "indentation": "<anything>"
  • "enableYAMLCompatibility": false or true
    • slightly change the whitespace around colons
  • "dropNullPlaceholders": false or true
    • Drop the "null" string from the writer's output for nullValues. Strictly speaking, this is not valid JSON. But when the output is being fed to a browser's JavaScript, it makes for smaller output and the browser can handle the output just fine.
  • "useSpecialFloats": false or true
    • If true, outputs non-finite floating point values in the following way: NaN values as "NaN", positive infinity as "Infinity", and negative infinity as "-Infinity".

You can examine 'settings_` yourself to see the defaults. You can also write and read them just like any JSON Value.

See also
setDefaults()

Definition at line 114 of file workspace/conan/dev_essential/1.3.3/dw/stable/package/37682420cd166e229516a41c8d6a139a0b13e1e1/include/json/writer.h.