diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d39190716..d771181e7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,3 +48,9 @@ At this point, it's our turn; if you've done everything well, we may just thank **A:** For simplicity purposes, we keep the direct write access to the main repository within a small group of core contributors. Since git forks , merges and pull requests are very easy and simple, this was not an obstacle so far. If you believe you really, really need write access to main repo, please contact the project maintainers at poco@pocoproject.org. --- + +**Q:** Why does compilation or test run fail on MinGW, Cygwin, [your platform of choice here]? + +**A:** Because we have limited manpower/resources available and can't keep up with every minute detail of every platform. Core team makes sure reasonably recent versions of **Visual Studio**, **clang** and **gcc** build/tests pass on Windows, OSX and Linux; the rest is left to the contributors and other parties with interest in particular platforms. As its name says, POCO is very portable and typically it is a minor code fix or ifdef that is needed to iron a wrinkle out; please consider changing it yourself and send us pull request - that will make everyone happy. If you are inclined to do so, please consider "owning" a platform or build system. It is not much of a commitment - you will be expected to (**a**) keep things tidy (i.e building cleanly with tests passing) in regards to your area and (**b**) respond to user's inquiries thereof. + +--- diff --git a/JSON/include/Poco/JSON/PrintHandler.h b/JSON/include/Poco/JSON/PrintHandler.h index ca3debdf2..b063565ad 100644 --- a/JSON/include/Poco/JSON/PrintHandler.h +++ b/JSON/include/Poco/JSON/PrintHandler.h @@ -115,7 +115,6 @@ private: unsigned _indent; std::string _tab; int _array; - bool _value; bool _objStart; }; diff --git a/JSON/src/PrintHandler.cpp b/JSON/src/PrintHandler.cpp index fabbf6246..0ce6f8901 100644 --- a/JSON/src/PrintHandler.cpp +++ b/JSON/src/PrintHandler.cpp @@ -27,8 +27,7 @@ PrintHandler::PrintHandler(unsigned indent): _out(std::cout), _indent(indent), _array(0), - _value(false), - _objStart(false) + _objStart(true) { } @@ -37,8 +36,7 @@ PrintHandler::PrintHandler(std::ostream& out, unsigned indent): _out(out), _indent(indent), _array(0), - _value(false), - _objStart(false) + _objStart(true) { } @@ -53,7 +51,7 @@ void PrintHandler::reset() _out.flush(); _tab = ""; _array = 0; - _value = false; + _objStart = true; } @@ -94,16 +92,17 @@ void PrintHandler::endObject() _tab.erase(_tab.length() - indent()); _out << endLine() << _tab << '}'; - if (array()) _value = true; + _objStart = false; } void PrintHandler::startArray() { + arrayValue(); _out << '[' << endLine(); _tab.append(indent(), ' '); ++_array; - _value = false; + _objStart = true; } @@ -113,18 +112,16 @@ void PrintHandler::endArray() _out << endLine() << _tab << ']'; --_array; poco_assert (_array >= 0); - _value = false; + _objStart = false; } void PrintHandler::key(const std::string& k) { - if (_value) - { - if (!_objStart) comma(); - _value = false; - } - _objStart = false; + if (!_objStart) comma(); + + _objStart = true; + _out << _tab; Stringifier::formatString(k, _out); if (!printFlat()) _out << ' '; @@ -137,7 +134,8 @@ void PrintHandler::null() { arrayValue(); _out << "null"; - _value = true; + + _objStart = false; } @@ -145,7 +143,7 @@ void PrintHandler::value(int v) { arrayValue(); _out << v; - _value = true; + _objStart = false; } @@ -153,7 +151,7 @@ void PrintHandler::value(unsigned v) { arrayValue(); _out << v; - _value = true; + _objStart = false; } @@ -162,7 +160,7 @@ void PrintHandler::value(Int64 v) { arrayValue(); _out << v; - _value = true; + _objStart = false; } @@ -170,7 +168,7 @@ void PrintHandler::value(UInt64 v) { arrayValue(); _out << v; - _value = true; + _objStart = false; } #endif @@ -179,7 +177,7 @@ void PrintHandler::value(const std::string& value) { arrayValue(); Stringifier::formatString(value, _out); - _value = true; + _objStart = false; } @@ -188,7 +186,7 @@ void PrintHandler::value(double d) { arrayValue(); _out << d; - _value = true; + _objStart = false; } @@ -196,7 +194,7 @@ void PrintHandler::value(bool b) { arrayValue(); _out << b; - _value = true; + _objStart = false; } @@ -207,12 +205,13 @@ void PrintHandler::comma() void PrintHandler::arrayValue() -{ - if (array()) - { - if (_value) comma(); +{ + + + if (!_objStart) comma(); + if (array()) { _out << _tab; - } + } } diff --git a/JSON/testsuite/src/JSONTest.cpp b/JSON/testsuite/src/JSONTest.cpp index baebf2a89..b84274d0a 100644 --- a/JSON/testsuite/src/JSONTest.cpp +++ b/JSON/testsuite/src/JSONTest.cpp @@ -1220,6 +1220,21 @@ void JSONTest::testPrintHandler() parser.reset(); parser.parse(json); assert (json == ostr.str()); + + json="[[\"a\"],[\"b\"],[[\"c\"],[\"d\"]]]"; + ostr.str(""); + pHandler->setIndent(0); + parser.reset(); + parser.parse(json); + assert (json == ostr.str()); + + json="[{\"1\":\"one\",\"0\":[\"zero\",\"nil\"]}]"; + ostr.str(""); + pHandler->setIndent(0); + parser.reset(); + parser.parse(json); + assert (json == ostr.str()); + } diff --git a/doc/poco.png b/doc/poco.png index 160e29d74..db3844cfc 100644 Binary files a/doc/poco.png and b/doc/poco.png differ