php json转数组提示null,json变换数组时中文为NULL解决方案

json转换数组时中文为NULL解决方案

$json='[{"ZtdID":"100000","ZtdNo":"001 ","ZtdName":"1号店 ","Address":"XX市ZZ区YY路01号铺 ","Remark":"","AreaID":"01","ZtdTel":"0000-8888888","ZtdContact":"张三"},{"ZtdID":"100001","ZtdNo":"002 ","ZtdName":"1号店 ","Address":"XX市ZZ区YY路01号铺 ","Remark":"","AreaID":"01","ZtdTel":"0000-8888888","ZtdContact":"李三"}]';

var_dump(json_decode($json,true));

?>

输出为NULL

经仔细查看,是编码问题,求解?

------解决方案--------------------

iconv('gbk','UTF-8','我是中文要转换成json');

转吧.PHP的json 中文没有支持gbk gb2312的格式

------解决方案--------------------

$json='[{"ZtdID":"100000","ZtdNo":"001 ","ZtdName":"1号店 ","Address":"XX市ZZ区YY路01号铺 ","Remark":"","AreaID":"01","ZtdTel":"0000-8888888","ZtdContact":"张三"},{"ZtdID":"100001","ZtdNo":"002 ","ZtdName":"1号店 ","Address":"XX市ZZ区YY路01号铺 ","Remark":"","AreaID":"01","ZtdTel":"0000-8888888","ZtdContact":"李三"}]';

debug( $json );

debug( json_decode($json,true) );

------------------输出正常

[{"ZtdID":"100000","ZtdNo":"001 ","ZtdName":"1号店 ","Address":"XX市ZZ区YY路01号铺 ","Remark":"","AreaID":"01","ZtdTel":"0000-8888888","ZtdContact":"张三"},{"ZtdID":"100001","ZtdNo":"002 ","ZtdName":"1号店 ","Address":"XX市ZZ区YY路01号铺 ","Remark":"","AreaID":"01","ZtdTel":"0000-8888888","ZtdContact":"李三"}]

Array

(

[0] => Array

(

[ZtdID] => 100000

[ZtdNo] => 001

[ZtdName] => 1号店

[Address] => XX市ZZ区YY路01号铺

[Remark] =>

[AreaID] => 01

[ZtdTel] => 0000-8888888

[ZtdContact] => 张三

)

[1] => Array

(

[ZtdID] => 100001

[ZtdNo] => 002

[ZtdName] => 1号店

[Address] => XX市ZZ区YY路01号铺

[Remark] =>

[AreaID] => 01

[ZtdTel] => 0000-8888888

[ZtdContact] => 李三

)

)

------解决方案--------------------

$json='{"ZtdID":"100000","ZtdNo":"001","ZtdName":"1号店","Address":"XX市ZZ区YY路01号铺","Remark":"","AreaID":"01","ZtdTel":"0000-8888888","ZtdContact":"张三"}';

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值