Skip to content

Commit 166b88e

Browse files
committed
revert 'Made it possible to drop null placeholders from array output.'
revert ae3c7a7
1 parent 3ce9872 commit 166b88e

File tree

3 files changed

+2
-25
lines changed

3 files changed

+2
-25
lines changed

include/json/writer.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,6 @@ class JSON_API FastWriter : public Writer {
158158

159159
void enableYAMLCompatibility();
160160

161-
/** \brief Drop the "null" string from the writer's output for nullValues.
162-
* Strictly speaking, this is not valid JSON. But when the output is being
163-
* fed to a browser's Javascript, it makes for smaller output and the
164-
* browser can handle the output just fine.
165-
*/
166-
void dropNullPlaceholders();
167-
168161
public: // overridden from Writer
169162
virtual std::string write(const Value& root);
170163

@@ -173,7 +166,6 @@ class JSON_API FastWriter : public Writer {
173166

174167
std::string document_;
175168
bool yamlCompatiblityEnabled_;
176-
bool dropNullPlaceholders_;
177169
};
178170

179171
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a

src/lib_json/json_writer.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,10 @@ Writer::~Writer() {}
279279
// //////////////////////////////////////////////////////////////////
280280

281281
FastWriter::FastWriter()
282-
: yamlCompatiblityEnabled_(false), dropNullPlaceholders_(false) {}
282+
: yamlCompatiblityEnabled_(false) {}
283283

284284
void FastWriter::enableYAMLCompatibility() { yamlCompatiblityEnabled_ = true; }
285285

286-
void FastWriter::dropNullPlaceholders() { dropNullPlaceholders_ = true; }
287-
288286
std::string FastWriter::write(const Value& root) {
289287
document_ = "";
290288
writeValue(root);
@@ -295,8 +293,7 @@ std::string FastWriter::write(const Value& root) {
295293
void FastWriter::writeValue(const Value& value) {
296294
switch (value.type()) {
297295
case nullValue:
298-
if (!dropNullPlaceholders_)
299-
document_ += "null";
296+
document_ += "null";
300297
break;
301298
case intValue:
302299
document_ += valueToString(value.asLargestInt());

src/test_lib_json/main.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,17 +1618,6 @@ JSONTEST_FIXTURE(ValueTest, zeroesInKeys) {
16181618
}
16191619
}
16201620

1621-
struct WriterTest : JsonTest::TestCase {};
1622-
1623-
JSONTEST_FIXTURE(WriterTest, dropNullPlaceholders) {
1624-
Json::FastWriter writer;
1625-
Json::Value nullValue;
1626-
JSONTEST_ASSERT(writer.write(nullValue) == "null\n");
1627-
1628-
writer.dropNullPlaceholders();
1629-
JSONTEST_ASSERT(writer.write(nullValue) == "\n");
1630-
}
1631-
16321621
struct StreamWriterTest : JsonTest::TestCase {};
16331622

16341623
JSONTEST_FIXTURE(StreamWriterTest, dropNullPlaceholders) {
@@ -2286,7 +2275,6 @@ int main(int argc, const char* argv[]) {
22862275
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, zeroes);
22872276
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, zeroesInKeys);
22882277

2289-
JSONTEST_REGISTER_FIXTURE(runner, WriterTest, dropNullPlaceholders);
22902278
JSONTEST_REGISTER_FIXTURE(runner, StreamWriterTest, dropNullPlaceholders);
22912279
JSONTEST_REGISTER_FIXTURE(runner, StreamWriterTest, writeZeroes);
22922280

0 commit comments

Comments
 (0)