mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-31 06:35:03 +01:00
stringify method output wrong json string #891
This commit is contained in:
parent
04caf94bb6
commit
08a85e84a4
@ -32,33 +32,35 @@ void Stringifier::stringify(const Var& any, std::ostream& out, unsigned int inde
|
||||
{
|
||||
if (step == -1) step = indent;
|
||||
|
||||
if ( any.type() == typeid(Object) )
|
||||
if (any.type() == typeid(Object))
|
||||
{
|
||||
const Object& o = any.extract<Object>();
|
||||
o.stringify(out, indent == 0 ? 0 : indent, step);
|
||||
}
|
||||
else if ( any.type() == typeid(Array) )
|
||||
else if (any.type() == typeid(Array))
|
||||
{
|
||||
const Array& a = any.extract<Array>();
|
||||
a.stringify(out, indent == 0 ? 0 : indent, step);
|
||||
}
|
||||
else if ( any.type() == typeid(Object::Ptr) )
|
||||
else if (any.type() == typeid(Object::Ptr))
|
||||
{
|
||||
const Object::Ptr& o = any.extract<Object::Ptr>();
|
||||
o->stringify(out, indent == 0 ? 0 : indent, step);
|
||||
}
|
||||
else if ( any.type() == typeid(Array::Ptr) )
|
||||
else if (any.type() == typeid(Array::Ptr))
|
||||
{
|
||||
const Array::Ptr& a = any.extract<Array::Ptr>();
|
||||
a->stringify(out, indent == 0 ? 0 : indent, step);
|
||||
}
|
||||
else if ( any.isEmpty() )
|
||||
else if (any.isEmpty())
|
||||
{
|
||||
out << "null";
|
||||
}
|
||||
else if ( any.isNumeric() || any.isBoolean() )
|
||||
else if (any.isNumeric() || any.isBoolean())
|
||||
{
|
||||
out << any.convert<std::string>();
|
||||
std::string value = any.convert<std::string>();
|
||||
if (any.type() == typeid(char)) formatString(value, out);
|
||||
else out << value;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -322,6 +322,11 @@ void JSONTest::testStringProperty()
|
||||
std::string value = test.convert<std::string>();
|
||||
assert(value.compare("value") == 0);
|
||||
|
||||
object.set("test2", 'a');
|
||||
std::ostringstream ostr;
|
||||
object.stringify(ostr);
|
||||
assert(ostr.str() == "{\"test\":\"value\",\"test2\":\"a\"}");
|
||||
|
||||
DynamicStruct ds = object;
|
||||
assert (!ds["test"].isEmpty());
|
||||
assert (ds["test"].isString());
|
||||
|
Loading…
x
Reference in New Issue
Block a user