【发布时间】:2013-11-06 20:32:30
【问题描述】:
我正在使用 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"
}
]
}
如何在 Qt 中创建三个包含 properties[x].ID、properties[x].PropertyName 和 properties[x].key 的数组?
编辑:
使用QScriptEngine我试过这个:
QString data = (QString)reply->readAll();
QScriptEngine engine;
QScriptValue result = engine.evaluate(data);
qDebug() << result.toString();
Debug 提示“SyntaxError: Parse error”
【问题讨论】:
-
其实我现在正在尝试使用 QScriptEngine。我现在正在看这个例子:makina-corpus.org/blog/access-json-webservice-qt-c