不知道如何解析、、、mark下

{"0101":{"4504":"\u8fce\u6c5f\u533a","4505":"\u5927\u89c2\u533a","4506":"\u7ecf\u6d4e\u5f00\u53d1\u533a"},"0102":{"4516":"\u79b9\u4f1a\u533a","4517":"\u868c\u5c71\u533a","4518":"\u9f99\u5b50\u6e56\u533a","4519":"\u6000\u8fdc\u53bf"},"0103":{"4534":"\u8c2f\u57ce\u533a"},"0104":{"4525":"\u5c45\u5de2\u533a","4526":"\u548c\u53bf","4527":"\u5e90\u6c5f\u53bf"},"0105":{"4554":"\u6c60\u5dde"},"0106":{"4544":"\u7405\u740a\u533a","4545":"\u7ecf\u6d4e\u6280\u672f\u5f00\u53d1\u533a","4546":"\u5929\u957f\u5e02","4547":"\u5b9a\u8fdc\u53bf","4548":"\u5357\u8c2f\u533a"},"0107":{"4521":"\u988d\u5dde\u533a","45....


$qu_json_data = file_get_contents("area.txt");
$qu_json = json_decode($qu_json_data);


stdClass Object ( [0101] => stdClass Object ( [4504] => 迎江区 [4505] => 大观区 [4506] => 经济开发区 ) [0102] => stdClass Object ( [4516] => 禹会区 [4517] => 蚌山区 [4518] => 龙子湖区 [4519] => 怀远县 ) [0103] => stdClass Object ( [4534] => 谯城区 ) [0104] => stdClass Object ( [4525] => 居巢区 [4526] => 和县 [4527] => 庐江县 ) [0105] => stdClass Object ( [4554] => 池州 ) [0106] => stdClass Object ( [4544] => 琅琊区 [4545] => 经济技术开发区 [4546] => 天长市 [4547] => 定远县 [4548] => 南谯区 ) [0107] => stdClass Object ( [4521] => 颍州区 [4522] => 颍泉区 [4523] => 颖东区 [4524] => 太和县 ) [0108] => stdClass Object ( [4487] => 蜀山区 [4488] => 庐阳区 [4489] => 包河区 [4490] => 瑶海区 [4491] => 经济技术开发区 [4492] => 高新技术开发区 [4493] => 政务文化新区 [4494] => 肥西县 [4495] => 双凤开发区 ) [0109] => stdClass Object ( [4555] => 淮北 [4556] => 烈山区 ) [0110] => stdClass Object ( [4520] => 田家庵区 ) [0111] => stdClass Object ( [4496] => 屯溪区 [4497] => 休宁县 [4498] => 黄山风景区 [4499] => 汤口 [4500] => 徽州区 [4501] => 黟县 [4502] => 歙县 [4503] => 黄山区 ) [0112] => stdClass Object ( [4549] => 裕安区 [4550] => 金安区 [4551] => 天堂寨镇 [4552] => 霍山县 [4553] => 霍邱县 ) [0113] => stdClass Object ( [4530] => 花山区 [4531] => 雨山区 [4532] => 濮塘风景区 [4533] => 当涂县 ) [0114] => stdClass Object ( [4536] => 北关区 [4537] => 墉桥区 ) [0115] => stdClass Object ( [4538] => 铜官山区 [4539] => 经济开发区 [4540] => 大通镇 [4541] => 五松镇 [4542] => 铜陵县 [4543] => 江南文化园 ) [0116] => stdClass Object ( [4507] => 南陵县 [4508] => 开发区 [4509] => 镜湖区 [4510] => 经济技术开发区 [4511] => 芜湖县 [4512] => 繁昌县 [4513] => 戈江区 [4514] => 鸠江区 [4515] => 三山区 ) [0117] => stdClass Object ( [4562] => 市区 [4563] => 泾县 [4564] => 绩溪县 ) [0201] => stdClass Object ( [5788] => 澳门 [5789] => 沊仔 [5790] => 路環 [5791] => 花地玛堂区 [5792] => 圣安多尼堂区 [5793] => 大堂区 [5794] => 望德堂区 [5795] => 风顺堂区 [5796] => 嘉模堂区(氹仔) [5797] => 圣方济各堂区(路环) [5798] => 路环 [5806] => 澳门市 ) [0301] => stdClass Object ( [3623] => 西城区 [3624] => 东城区 [3625] => 朝阳区 [3626] => 宣武区 [3627] => 崇文区 [3628] => 丰台区 [3629] => 石景山区 [3630] => 海淀区 [3631] => 密云县 [3632] => 顺义区 [3633] => 延庆县 [3634] => 通州区 [3635] => 昌平区 [3636] => 怀柔区 [3637] => 平谷区 [3638] => 门头沟区 [3639] => 房山区 [3640] => 大兴区 ) [0401] => stdClass Object ( [4581] => 鼓楼区 [4582] => 台江区 [4583] => 晋安区 [4584] => 马尾区 [4585] => 仓山区 [4586] => 连江县 ) [0402] => stdClass Object ( [4605] => 新罗区 [4606] => 长汀县 [4607] => 连城县 [4608] => 永定县 [4609] => 武平县 ) [0403] => Array ( ) [0404] => stdClass Object ( [4616] => 蕉城区 [4617] => 东侨区 [4618] => 霞浦县 ) [0405] => stdClass Object ( [4597] => 城厢区 [4598] => 涵江区 [4599] => 荔城区 [4600] => 秀屿区 ) [0406] => stdClass Object ( [4587] => 丰泽区 [4588] => 鲤城区 [4589] => 泉港区 [4590] => 崇武镇 [4591] => 洛江区 [4592] => 清濛经济技术开发区 [4593] => 惠安县 ) [0407] => stdClass Object ( [4610] => 永安市 [4611] => 梅列区 [4612] => 泰宁县 [4613] => 沙县 ) [0408] => stdClass Object ( [4575] => 思明区 [4576] => 集美区 [4577] => 同安区 [4578] => 海沧区 [4579] => 湖里区 [4580] => 翔安区 ) [0409] => stdClass Object ( [4601] => 芗城区 [4602] => 东山县 [4603] => 漳州 [4604] => 云霄县 ) [0501] => stdClass Object ( [5683] => 西区 [5684] => 景泰县 [5685] => 会宁县 ) [0502] => Array ( ) [0503] => stdClass Object ( [5690] => 甘南藏族自治州 ) [0504] => stdClass Object ( [5671] => 市区 ) [0505] => stdClass Object ( [5688] => 市区 ) [0506] => stdClass Object ( [5682] => 市区 ) [0507] => stdClass Object ( [5663] => 城关区 [5664] => 七里河区 [5665] => 西固区 [5666] => 安宁区 [5667] => 红古区 [5668] => 永登 [5669] => 皋兰县 [5670] => 榆中县 ) [0508] => Array ( ) [0509] => Array ( ) [0510] => stdClass Object ( [5687] => 市区 ) [0511] => stdClass Object ( [5691] => 西峰区 [5692] => 市区 [5693] => 经济开发区 ) [0512] => stdClass Object ( [5679] => 秦州区 [5680] => 麦积区 [5681] => 麦积镇 ) [0513] => stdClass Object ( [5686] => 市区 ) [0514] => stdClass Object ( [5677] => 市区 [5678] => 临泽县 ) 




产生原因:

$res = json_decode($res);

$res['key']; //把 json_decode() 后的对象当作数组使用。

网上令狐葱提供了两种解决方法:

1、使用 json_decode($d, true)。就是使json_decode 的第二个变量设置为 true。

2、json_decode($res) 返回的是一个对象, 不可以使用 $res['key'] 进行访问, 换成 $res->key  就可以了。

参考手册:json_decode
Return Values:Returns an object or if the optional assoc parameter is TRUE, an associative array is instead returned.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值