fixed GH #410: Bug in JSON::Object.stringify() in 1.5.2

This commit is contained in:
Alex Fabijanic
2014-04-28 21:43:57 -05:00
parent f19d1cb041
commit 4d366250e1
4 changed files with 18 additions and 8 deletions

View File

@@ -1215,12 +1215,13 @@ void JSONTest::testPrintHandler()
void JSONTest::testStringify()
{
Poco::JSON::Object obj;
obj.set("one","two");
obj.stringify(std::cout,4); //this works
obj.stringify(std::cout,1); //this never returns
std::cout << std::endl;
Object jObj(false);
jObj.set("foo", 0);
jObj.set("bar", 0);
jObj.set("baz", 0);
std::stringstream ss;
jObj.stringify(ss);
assert(ss.str() == "{\"bar\":0,\"baz\":0,\"foo\":0}");
std::string json = "{ \"Simpsons\" : { \"husband\" : { \"name\" : \"Homer\" , \"age\" : 38 }, \"wife\" : { \"name\" : \"Marge\", \"age\" : 36 }, "
"\"children\" : [ \"Bart\", \"Lisa\", \"Maggie\" ], "
@@ -1348,6 +1349,14 @@ void JSONTest::testStringify()
void JSONTest::testStringifyPreserveOrder()
{
Object jObj(true);
jObj.set("foo", 0);
jObj.set("bar", 0);
jObj.set("baz", 0);
std::stringstream ss;
jObj.stringify(ss);
assert(ss.str() == "{\"foo\":0,\"bar\":0,\"baz\":0}");
std::string json = "{ \"Simpsons\" : { \"husband\" : { \"name\" : \"Homer\" , \"age\" : 38 }, \"wife\" : { \"name\" : \"Marge\", \"age\" : 36 }, "
"\"children\" : [ \"Bart\", \"Lisa\", \"Maggie\" ], "
"\"address\" : { \"number\" : 742, \"street\" : \"Evergreen Terrace\", \"town\" : \"Springfield\" } } }";