我正在使用 Qt5。我正在尝试从 json 对象中获取值。这是我试图从中获取数据的 json 对象的样子:
{
"success": true,
"properties": [
{
"ID": 1001,
"PropertyName": "McDonalds",
"key": "00112233445566778899aabbccddeeff"
},
{
"ID": 1002,
"PropertyName": "Burger King",
"key": "10112233445566778899aabbccddeeff"
},
{
"ID": 1003,
"PropertyName": "Taco Bell",
"key": "20112233445566778899aabbccddeeff"
}
]
}
如何创建三个包含的数组properties[x].ID
,properties[x].PropertyName
properties[x].key
在 Qt 中和的数组?
编辑:
使用QScriptEngine
我试过这个:
QString data = (QString)reply->readAll();
QScriptEngine engine;
QScriptValue result = engine.evaluate(data);
qDebug() << result.toString();
调试说“语法错误:解析错误”