jsondict是一種現在移動互聯網用得比較多的一種定義數據的結構,下面來介紹一下
cpp
this->index = index;
this->type = jsonDict["shop"][index]["type"].GetString();
this->gold = jsonDict["shop"][index]["gold"].GetInt();
this->img = jsonDict["shop"][index]["img"].GetString();
this->id = jsonDict["shop"][index]["id"].GetInt();
this->desc = jsonDict["shop"][index]["desc"].GetString();
data.json"shop":
[
{
"type":"item",
"id":0,
"gold":300,
"img":"zhuangb025.png",
"desc":"獵槍:傷害高,後坐力小,高仿獵槍,不傷手無殘留,頗受男同胞們的喜歡。"
},
{
"type":"item",
"id":1,
"gold":800,
"img":"zhuangb079.png",
"desc":"捕獵網:覆蓋面積更廣,比它網好用多了,喜歡養小貓小狗的人不妨買回去試一下"
},
{
"type":"item",
"id":2,
"gold":6000,
"img":"zhuangb080.png",
"desc":"彈射陷阱:全國銷量領先的捕獵器件,彈彈彈,彈走小怪獸"
},
this->type = jsonDict["shop"][index]["type"].GetString();
的意思是給type賦值,值爲shop類的index(索引)若index爲0,則爲第一個大括號的內容