json格式分析: 一般json数据就是表示进行过编码的字符串 用双引号或者单引号括起来
json格式类型:
JSON对象
{ "name":"smith", "age":30, "sex":男 }
对象的属性也可以是JSON对象
{ "name":"smith", "age":18 "sex":男 "school":{ "sname":"武汉大学", "address":"樱花路" } }
JSON格式表示简单数组
保存名字的数字: ["尼古拉斯","斯巴达","雅典娜"]
保存雇员的信息: ["尼古拉斯",1001,"总裁",7788,50000.00,10000.0]
对象数组
在一个数字中保存多个JSON对象
[
{
"title":"Java实战经典开发",
"edition":3,
"author":["smith","尼古拉斯","斯巴达"]
},
{
"title":"Oracle实战经典开发",
"edition":3,
"author":["smith","尼古拉斯","斯巴达"]
}
]
json类型都是键值对 冒号组成的
而数组的表现形式是用箭头的形式表示的
json_decode 对 JSON 格式的字符串进行解码
例子:

返回结果是:
array(5) {
["a"]=>
int(1)
["b"]=>
int(2)
["c"]=>
int(3)
["d"]=>
int(4)
["e"]=>
int(5)
}
json_encode 对变量进行 JSON 编码

返回结果:
{"a":1,"b":2,"c":3,"d":4,"e":5}