[cocos2dx]学习笔记 jsonDict
2014-08-01 16:26
204 查看
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,则为第一个大括号的内容
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,则为第一个大括号的内容
相关文章推荐
- Cocos2dx学习笔记37 Json 数据解析rapidjson库的使用
- json学习笔记
- extjs学习笔记三[Ext+json+jsp构建的动态树]
- Json.Net学习笔记(十二) 协议解析
- Spring MVC 学习笔记 json格式的输入和输出
- Json.Net 学习笔记(二) Linq to Json
- jQuery学习笔记--之json解析详解
- jQuery学习笔记--ajax查询,jQuery解析返回的json数据 详解
- JSON学习笔记
- JSON学习笔记
- Json.Net 学习笔记(一)
- extJs 2.1学习笔记(JSON序列化篇)
- json 入门学习笔记 示例代码
- json 入门学习笔记 示例代码
- Spring MVC 学习笔记 九 json格式的输入和输出
- Javascript学习笔记8 用JSON做原型
- 学习笔记1 json的学习
- 【AJAX学习笔记】JSON数据编码解码技术
- Json.Net学习笔记(十) 保持对象引用
- Python 学习笔记【dict的操作方法】