介绍:
- 一种与服务器数据交换的简单的数据格式
- 伪对象
语法:
- 映射集合对象用“{ }”表示
- 并列数据集合用方括号“[ ]”表示
- 映射关系用冒号“:”表示
- 并列数据用“,”分割
例子:
{
"fimaily": [
{
"name": "baba",
"age": 32,
"car": [
"car1",
"car2",
4
],
"childen": [
{
"childen1": {
"name": "lili",
"age": 15
}
},
{
"childen2": {
"name": "jim",
"age": 10
}
}
]
},
{
"name": "mama"
}
],
"money": 10000,
"dogs": [
{
"dog1": {
"name": "pp",
"age": 2
}
}
]
}
在OC中
<span style="font-size:14px;">NSDictionary *oldDic =[NSDictionary dictionaryWithObjectsAndKeys:@"name",@"tom",@"age",@(23), nil];
NSDictionary *newDic = @{@"name":@"tom",@"age":@(23)};</span>
<span style="font-size:14px;">
NSMutableArray *oldArray = [NSMutableArray arrayWithObjects:@"frist",oldDic,nil];
NSMutableArray *newArray = @[@"frist",newDic];</span>
记录自己的学习
]
}