mirror of https://gitee.com/openkylin/lshw.git
[PATCH] correct "JSON output format" without/with all class.
test pass on my machine. Signed-off-by: Yuan-Chen Cheng <ycheng.tw@gmail.com> Gbp-Pq: Name 82393aa9b59307a443677df7340a1dd38847a5ef.patch
This commit is contained in:
parent
4182469fa0
commit
20b636220b
|
@ -1653,13 +1653,29 @@ string hwNode::asJSON(unsigned level)
|
||||||
resources.clear();
|
resources.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < countChildren(); i++)
|
if(countChildren()>0)
|
||||||
{
|
{
|
||||||
out << getChild(i)->asJSON(visible(getClassName()) ? level + 2 : 1);
|
bool childOutputed = false;
|
||||||
if (visible(getChild(i)->getClassName()))
|
for (unsigned int i = 0; i < countChildren(); i++)
|
||||||
{
|
{
|
||||||
out << "," << endl;
|
string childJSON = getChild(i)->asJSON(visible(getClassName()) ? level + 2 : 1);
|
||||||
|
string childJSONstrip = strip(childJSON);
|
||||||
|
if (childJSONstrip.length() > 0)
|
||||||
|
{
|
||||||
|
if (!childOutputed)
|
||||||
|
{
|
||||||
|
if(visible(getClassName()))
|
||||||
|
out << "," << endl << spaces(2*level+2) << "\"children\" : [" << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
out << "," << endl;
|
||||||
|
childOutputed = true;
|
||||||
|
out << childJSON;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(visible(getClassName()) && childOutputed)
|
||||||
|
out << endl << spaces(2*level+2) << "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(visible(getClassName()))
|
if(visible(getClassName()))
|
||||||
|
@ -1670,7 +1686,6 @@ string hwNode::asJSON(unsigned level)
|
||||||
|
|
||||||
if (level == 0)
|
if (level == 0)
|
||||||
{
|
{
|
||||||
out.seekp(-2, std::ios_base::end);
|
|
||||||
out << endl << "]" << endl;
|
out << endl << "]" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue