mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-01-04 00:45:22 +08:00
revert 'Made it possible to drop null placeholders from array output.'
revert ae3c7a7aabfb345968a65001ea9bc25f1e2bb405
This commit is contained in:
parent
254fe6a07a
commit
6f6ddaa91c
@ -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 <a HREF="http://www.json.org">JSON</a> format in a
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user