diff --git a/CHANGELOG b/CHANGELOG index a40cef04f..c63bcf80b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,10 +13,12 @@ Release 1.5.2 (2013-03-??) - merged GH #86: Invalid pointers to vector internals (by Adrian Imboden) - automatic library initialization macros - fixed GH #110: WebSocket accept() fails when Connection header contains multiple tokens -- fixed GH# 71: WebSocket and broken Timeouts (POCO_BROKEN_TIMEOUTS) +- fixed GH #71: WebSocket and broken Timeouts (POCO_BROKEN_TIMEOUTS) - fixed a warning in Poco/Crypto/OpenSSLInitializer.h -- fixed GH# 109: Bug in Poco::Net::SMTPClientSession::loginUsingPlain +- fixed GH #109: Bug in Poco::Net::SMTPClientSession::loginUsingPlain - added clang libc++ build configurations for Darwin and iPhone (Andrea Bigagli) +- fixed GH #116: Wrong timezone parsing in DateTimeParse (fix by Matej Knopp) +- fixed GH #118: JSON::Object::stringify endless loop Release 1.5.1 (2013-01-11) ========================== diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 155a3d4d3..e1cb8b150 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -32,6 +32,7 @@ Roger Meier Mathaus Mendel Arturo Castro Adrian Imboden +Matej Knopp -- $Id$ diff --git a/JSON/include/Poco/JSON/Object.h b/JSON/include/Poco/JSON/Object.h index 1ea3cc3b7..34dff1e38 100644 --- a/JSON/include/Poco/JSON/Object.h +++ b/JSON/include/Poco/JSON/Object.h @@ -146,6 +146,7 @@ public: /// Removes the property with the given key private: + //TODO: unordered map typedef std::map ValueMap; ValueMap _values; }; diff --git a/JSON/src/Array.cpp b/JSON/src/Array.cpp index 05e922c48..0936825ad 100644 --- a/JSON/src/Array.cpp +++ b/JSON/src/Array.cpp @@ -123,41 +123,22 @@ bool Array::isObject(unsigned int index) const void Array::stringify(std::ostream& out, unsigned int indent) const { out << "["; - if ( indent > 0 ) - out << std::endl; - for(ValueVec::const_iterator it = _values.begin(); it != _values.end();) + if (indent > 0) out << std::endl; + + for (ValueVec::const_iterator it = _values.begin(); it != _values.end();) { - for(int i = 0; i < indent; i++) - { - out << ' '; - } + for(int i = 0; i < indent; i++) out << ' '; Stringifier::stringify(*it, out, indent); if ( ++it != _values.end() ) { out << ","; - if ( indent > 0 ) - { - out << std::endl; - } + if ( indent > 0 ) out << std::endl; } } - if ( indent > 0 ) - { - out << std::endl; - } - - if ( indent > 0 ) - indent -= 2; - - for(int i = 0; i < indent; i++) - { - out << ' '; - } - out << "]"; } diff --git a/JSON/src/Object.cpp b/JSON/src/Object.cpp index 0ada7d6dc..a54c5f527 100644 --- a/JSON/src/Object.cpp +++ b/JSON/src/Object.cpp @@ -117,41 +117,23 @@ void Object::getNames(std::vector& names) const void Object::stringify(std::ostream& out, unsigned int indent) const { out << '{'; - if ( indent > 0 ) - { - out << std::endl; - } - for(ValueMap::const_iterator it = _values.begin(); it != _values.end();) + if (indent > 0) out << std::endl; + + for (ValueMap::const_iterator it = _values.begin(); it != _values.end();) { - for(int i = 0; i < indent; i++) - { - out << ' '; - } + for(int i = 0; i < indent; i++) out << ' '; out << '"' << it->first << '"'; out << (( indent > 0 ) ? " : " : ":"); Stringifier::stringify(it->second, out, indent); - if ( ++it != _values.end() ) - { - out << ','; - } + if ( ++it != _values.end() ) out << ','; - if ( indent > 0 ) - { - out << std::endl; - } + if ( indent > 0 ) out << std::endl; } - - if ( indent > 0 ) - indent -= 2; - for(int i = 0; i < indent; i++) - { - out << ' '; - } - + out << '}'; } diff --git a/JSON/testsuite/src/JSONTest.cpp b/JSON/testsuite/src/JSONTest.cpp index 65c57ef31..a0e1a1617 100644 --- a/JSON/testsuite/src/JSONTest.cpp +++ b/JSON/testsuite/src/JSONTest.cpp @@ -195,7 +195,7 @@ void JSONTest::testNumberProperty() void JSONTest::testUnsignedNumberProperty() { - // 4294967295 == unsigned(-1) + // 4294967295 == unsigned(-1) std::string json = "{ \"test\" : 4294967295 }"; Parser parser; Var result; @@ -256,7 +256,7 @@ void JSONTest::testNumber64Property() void JSONTest::testUnsignedNumber64Property() { - // 18446744073709551615 == UInt64(-1) + // 18446744073709551615 == UInt64(-1) std::string json = "{ \"test\" : 18446744073709551615 }"; Parser parser; Var result; @@ -801,6 +801,33 @@ void JSONTest::testQuery() } +void JSONTest::testStringify() +{ + std::string json = "{ \"name\" : \"Franky\", \"children\" : [ \"Jonas\", \"Ellen\" ] }"; + Parser parser; + Var result; + + try + { + DefaultHandler handler; + parser.setHandler(&handler); + parser.parse(json); + result = handler.result(); + } + catch(JSONException& jsone) + { + std::cout << jsone.message() << std::endl; + assert(false); + } + + assert(result.type() == typeid(Object::Ptr)); + std::ostringstream ostr; + Stringifier::stringify(result, ostr); + //TODO: need map that does not order for internal container + assert (ostr.str() == "{\"name\":\"Franky\",\"children\":[\"Jonas\",\"Ellen\"]}"); +} + + void JSONTest::testValidJanssonFiles() { Poco::Path pathPattern(getTestFilesPath("valid")); @@ -1044,6 +1071,7 @@ CppUnit::Test* JSONTest::suite() CppUnit_addTest(pSuite, JSONTest, testDoubleElement); CppUnit_addTest(pSuite, JSONTest, testOptValue); CppUnit_addTest(pSuite, JSONTest, testQuery); + CppUnit_addTest(pSuite, JSONTest, testStringify); CppUnit_addTest(pSuite, JSONTest, testValidJanssonFiles); CppUnit_addTest(pSuite, JSONTest, testInvalidJanssonFiles); CppUnit_addTest(pSuite, JSONTest, testInvalidUnicodeJanssonFiles); diff --git a/JSON/testsuite/src/JSONTest.h b/JSON/testsuite/src/JSONTest.h index 2ad25e3c3..7f0b92049 100644 --- a/JSON/testsuite/src/JSONTest.h +++ b/JSON/testsuite/src/JSONTest.h @@ -73,6 +73,8 @@ public: void testDoubleElement(); void testOptValue(); void testQuery(); + void testStringify(); + void testValidJanssonFiles(); void testInvalidJanssonFiles(); void testTemplate();