QScript 解析json
来源:互联网 发布:交换机端口流量监控 编辑:程序博客网 时间:2024/06/16 08:04
- #include <QtGui/QApplication>
- #include <QtCore/QString>
- #include <QtCore/QStringList>
- #include <QtScript/QScriptEngine>
- #include <QtScript/QScriptValue>
- #include <QtScript/QScriptValueIterator>
- #include <QtCore/QtDebug>
- int main(int argc, char *argv[])
- {
- QApplication app(argc, argv);
- QString strJson = "{\"department\":\"computer science\", \"person number\":\"45\", \"student\":[{\"Name\":\"ccf\",\"Math\":\"95\", \"Chinese\":\"84\"}, {\"Name\":\"zhangsan\",\"Math\":\"75\", \"Chinese\":\"70\"}]}";
- QScriptEngine engine;
- QScriptValue sc = engine.evaluate("value=" + strJson);
- qDebug() << "department:" << sc.property("department").toString();//解析字段
- if (sc.property("student").isArray()) //解析数组
- {
- QScriptValueIterator it(sc.property("student"));
- while(it.hasNext())
- {
- it.next();
- if (!it.value().property("Name").toString().isEmpty())
- {
- qDebug() << "Name :" << it.value().property("Name").toString();
- qDebug() << "Math :" << it.value().property("Math").toString();
- qDebug() << "Chinese :" << it.value().property("Chinese").toString();
- }
- }
- }
- return app.exec();
- }
0 0
- QScript 解析json
- QScript
- QT学习之QScript
- 【JSON解析】JSON解析
- 解析JSON
- Json解析
- JSON解析
- JSON解析
- json解析
- Json解析
- Json解析
- JSON解析
- Json解析
- Json解析
- JSON解析
- JSON解析
- json 解析
- Json解析
- activity设置背景色为透明
- 图像识别技术
- Android 更改弹出对话框的大小
- (15)shell 输入输出重定向
- NSFileManager管理文件和目录
- QScript 解析json
- iOS自定义NavigationBar
- Jquery DataTables 用法分享
- linux环境下实现图片的读取和显示
- OkHttp学习 - POM 文件
- 磁盘映射的创建
- Codeforces round341 div2
- (16)shell文件包含
- webview加载页面--