[cocos2dx]学习笔记 jsonDict

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,则为第一个大括号的内容


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值