0
我試圖去從一些返回JSON的天氣API獲取數據。 我讀過列表中的每個項目都被認爲是沒有「標籤」的節點,但是,這裏列表中包含兩個節點。如何訪問description
標籤,因爲root.get<string>("weather.description")
會拋出Node does not exist
錯誤?Boost :: ptree - 訪問包含在列表中的屬性樹節點
我試過(這沒什麼返回):
for (auto it: root.get_child("weather")) {
cout << it.first.data() << "+";
cout << it.second.data() << endl;
}
weather.json:
{
"weather": [
{
"id": "701",
"main": "Mist",
"description": "brume",
"icon": "50n"
},
{
"id": "502",
"main": "Sun",
"description": "soleil",
"icon": "50b"
}
]
}