Rumah > pembangunan bahagian belakang > tutorial php > 接口传过去的值,别人解析

接口传过去的值,别人解析

WBOY
Lepaskan: 2016-06-23 13:37:57
asal
996 orang telah melayarinya

??{	"status":"ok",	"msg":"登录成功!",	"data":[		{			"uid":"27",			"username":"123",			"password":"202cb962ac59075b964b07152d234b70",			"nickname":"aaa",			"telephone":"",			"phone":null,			"qq":"",			"fax":null,			"email":"",			"department":"",			"job":null,			"seniority":"0",			"integral":"10",			"strength":null,			"ip":null,			"time":null		}	]}
Salin selepas log masuk



不知道是不是我这json格式错了?


回复讨论(解决方案)

1、有多个 BOM 头
2、null 也要用双引号括起来

print_r(json_decode($s));
解码后

stdClass Object(    [status] => ok    [msg] => 登录成功!    [data] => Array        (            [0] => stdClass Object                (                    [uid] => 27                    [username] => 123                    [password] => 202cb962ac59075b964b07152d234b70                    [nickname] => aaa                    [telephone] =>                     [phone] => null                    [qq] =>                     [fax] => null                    [email] =>                     [department] =>                     [job] => null                    [seniority] => 0                    [integral] => 10                    [strength] => null                    [ip] => null                    [time] => null                )        ))
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk


1、有多个 BOM 头
2、null 也要用双引号括起来

print_r(json_decode($s));
解码后

stdClass Object(    [status] => ok    [msg] => 登录成功!    [data] => Array        (            [0] => stdClass Object                (                    [uid] => 27                    [username] => 123                    [password] => 202cb962ac59075b964b07152d234b70                    [nickname] => aaa                    [telephone] =>                     [phone] => null                    [qq] =>                     [fax] => null                    [email] =>                     [department] =>                     [job] => null                    [seniority] => 0                    [integral] => 10                    [strength] => null                    [ip] => null                    [time] => null                )        ))
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk



我发现哪里错了。。 json格式应该是没错。。
但是我的json第一个大括号错了。。 我在JSONLint 检验了一下。 我把我的大括号删了重新输入。就正确了
这个是因为什么啊? 我用同样的查询语句。。有的可以,有的不行。。
而且文件编码都是utf-8

推荐一个网站给你检测一下你的json数据格式吧, http://bejson.com

bejson正解

1、有多个 BOM 头
2、null 也要用双引号括起来

print_r(json_decode($s));
解码后

stdClass Object(    [status] => ok    [msg] => 登录成功!    [data] => Array        (            [0] => stdClass Object                (                    [uid] => 27                    [username] => 123                    [password] => 202cb962ac59075b964b07152d234b70                    [nickname] => aaa                    [telephone] =>                     [phone] => null                    [qq] =>                     [fax] => null                    [email] =>                     [department] =>                     [job] => null                    [seniority] => 0                    [integral] => 10                    [strength] => null                    [ip] => null                    [time] => null                )        ))
Salin selepas log masuk
Salin selepas log masuk
Salin selepas log masuk



我明白了 。。 是多个bom头 的问题。。测试了好久。。终于弄明白了。。
膜拜啊。。今天又学了一招。。
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan