我有一个JSON字符串
{
"FirstName": "John",
"LastName": "Doe",
"Age": 43,
"Address": {
"Street": "Downing Street 10",
"City": "London",
"Country": "Great Britain"
},
"Phone numbers": [
"+44 1234567",
"+44 2345678"
]
}
在QString变量中,我在Stackoverflow上找到了一种格式化XML的方法:
QString responseData = "";
responseData = networkResponse->readAll();
QString formattedXMLResponse;
QDomDocument input;
input.setContent(responseData);
QDomDocument output(input);
QTextStream stream(&formattedXMLResponse);
output.save(stream, 2);
ui->outputTB->setPlainText(formattedXMLResponse);
但是这段代码只适用于XML格式。你有什么想法可以格式化JSON吗?