diff --git a/include/json/writer.h b/include/json/writer.h index 40421c6..2da72b6 100644 --- a/include/json/writer.h +++ b/include/json/writer.h @@ -158,13 +158,6 @@ public: void enableYAMLCompatibility(); - /** \brief 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. - */ - void dropNullPlaceholders(); - public: // overridden from Writer virtual std::string write(const Value& root); @@ -173,7 +166,6 @@ private: std::string document_; bool yamlCompatiblityEnabled_; - bool dropNullPlaceholders_; }; /** \brief Writes a Value in JSON format in a diff --git a/src/lib_json/json_writer.cpp b/src/lib_json/json_writer.cpp index 0be1184..5510eb1 100644 --- a/src/lib_json/json_writer.cpp +++ b/src/lib_json/json_writer.cpp @@ -284,12 +284,10 @@ Writer::~Writer() {} // ////////////////////////////////////////////////////////////////// FastWriter::FastWriter() - : yamlCompatiblityEnabled_(false), dropNullPlaceholders_(false) {} + : yamlCompatiblityEnabled_(false) {} void FastWriter::enableYAMLCompatibility() { yamlCompatiblityEnabled_ = true; } -void FastWriter::dropNullPlaceholders() { dropNullPlaceholders_ = true; } - std::string FastWriter::write(const Value& root) { document_ = ""; writeValue(root); @@ -300,8 +298,7 @@ std::string FastWriter::write(const Value& root) { void FastWriter::writeValue(const Value& value) { switch (value.type()) { case nullValue: - if (!dropNullPlaceholders_) - document_ += "null"; + document_ += "null"; break; case intValue: document_ += valueToString(value.asLargestInt()); diff --git a/src/test_lib_json/main.cpp b/src/test_lib_json/main.cpp index cb5c6eb..9331c16 100644 --- a/src/test_lib_json/main.cpp +++ b/src/test_lib_json/main.cpp @@ -1618,17 +1618,6 @@ JSONTEST_FIXTURE(ValueTest, zeroesInKeys) { } } -struct WriterTest : JsonTest::TestCase {}; - -JSONTEST_FIXTURE(WriterTest, dropNullPlaceholders) { - Json::FastWriter writer; - Json::Value nullValue; - JSONTEST_ASSERT(writer.write(nullValue) == "null\n"); - - writer.dropNullPlaceholders(); - JSONTEST_ASSERT(writer.write(nullValue) == "\n"); -} - struct StreamWriterTest : JsonTest::TestCase {}; JSONTEST_FIXTURE(StreamWriterTest, dropNullPlaceholders) { @@ -2286,7 +2275,6 @@ int main(int argc, const char* argv[]) { JSONTEST_REGISTER_FIXTURE(runner, ValueTest, zeroes); JSONTEST_REGISTER_FIXTURE(runner, ValueTest, zeroesInKeys); - JSONTEST_REGISTER_FIXTURE(runner, WriterTest, dropNullPlaceholders); JSONTEST_REGISTER_FIXTURE(runner, StreamWriterTest, dropNullPlaceholders); JSONTEST_REGISTER_FIXTURE(runner, StreamWriterTest, writeZeroes);