{
"FirstName": "三",
"LastName": "张",
"Age": 43,
"Address": {
"Street": "长安街",
"City": "北京",
"Country": "中国"
},
"Phone numbers": [
"+44 1234567",
"+44 2345678"
]
"FirstName": "三",
"LastName": "张",
"Age": 43,
"Address": {
"Street": "长安街",
"City": "北京",
"Country": "中国"
},
"Phone numbers": [
"+44 1234567",
"+44 2345678"
]
}
json配置文件的格式 可以使用http://www.bejson.com/检验json格式是否正确
//1.打开文件
QFile loadFile("test.json");
loadFile.open(QIODevice::ReadOnly | QIODevice::Text);
cout << QString("姓名:") << obj["LastName"].toString()
<< obj["FirstName"].toString() << endl;这是读取 FirstName 这个类型的配置
如果是int的数据不需要加“”, 最后一个类型后面不要加,