mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-23 01:38:11 +08:00
Made it possible to drop null placeholders from array output.
This can be used when it's clear that the consumer is able to deal with this, as web browsers are. Thanks to Yatin Chawathe for the patch.
This commit is contained in:
@@ -192,7 +192,8 @@ Writer::~Writer()
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
FastWriter::FastWriter()
|
||||
: yamlCompatiblityEnabled_( false )
|
||||
: yamlCompatiblityEnabled_( false ),
|
||||
dropNullPlaceholders_( false )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -204,6 +205,13 @@ FastWriter::enableYAMLCompatibility()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FastWriter::dropNullPlaceholders()
|
||||
{
|
||||
dropNullPlaceholders_ = true;
|
||||
}
|
||||
|
||||
|
||||
std::string
|
||||
FastWriter::write( const Value &root )
|
||||
{
|
||||
@@ -220,7 +228,7 @@ FastWriter::writeValue( const Value &value )
|
||||
switch ( value.type() )
|
||||
{
|
||||
case nullValue:
|
||||
document_ += "null";
|
||||
if (!dropNullPlaceholders_) document_ += "null";
|
||||
break;
|
||||
case intValue:
|
||||
document_ += valueToString( value.asLargestInt() );
|
||||
|
Reference in New Issue
Block a user