mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-23 16:48:06 +02:00
GH #118: JSON::Object::stringify endless loop
This commit is contained in:
@@ -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 << "]";
|
||||
}
|
||||
|
||||
|
@@ -117,41 +117,23 @@ void Object::getNames(std::vector<std::string>& 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 << '}';
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user