diff --git a/src/core/hw.cc b/src/core/hw.cc index 1c1dad46..b52f2a07 100644 --- a/src/core/hw.cc +++ b/src/core/hw.cc @@ -1650,20 +1650,28 @@ string hwNode::asJSON(unsigned level) resources.clear(); } - if(!::enabled("output:list") && countChildren()>0) + if(countChildren()>0) { - out << "," << endl; - out << spaces(2*level+2); - out << "\"children\" : ["; + bool needcomma = false; + if(visible(getClassName())){ + out << "," << endl; + out << spaces(2*level+2); + out << "\"children\" : ["; + } for (unsigned int i = 0; i < countChildren(); i++) { - out << getChild(i)->asJSON(visible(getClassName()) ? level + 2 : 1); - if (visible(getChild(i)->getClassName()) && iasJSON(visible(getClassName()) ? level + 2 : 1); + + if(needcomma && strip(json)!="") { out << "," << endl; } + out << json; + needcomma |= strip(json)!=""; + } + if(visible(getClassName())){ + out << "]"; } - out << "]"; } if(visible(getClassName())) @@ -1672,20 +1680,6 @@ string hwNode::asJSON(unsigned level) out << "}"; } - if(::enabled("output:list") && countChildren()>0) - { - bool needcomma = visible(getClassName()); - for (unsigned int i = 0; i < countChildren(); i++) - { - string json = getChild(i)->asJSON(visible(getClassName()) ? level + 2 : 1); - - if(needcomma && strip(json)!="") - out << "," << endl; - out << getChild(i)->asJSON(visible(getClassName()) ? level + 2 : 1); - needcomma |= strip(json)!=""; - } - } - if (::enabled("output:list") && level == 0) { out << endl << "]" << endl;