欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

这样解析json为什么没效果?

程序员文章站 2022-06-04 08:57:42
...

$json的内容大概是这样的:

{"pagination":{},"meta":{"code":200},"data":[{"attribution":null,"tags":[],"type":"image","location":null,"comments":{"count":0},"filter":"Normal","created_time":"1453516817","link":"https:\/\/www.instagram.com\/p\/BA3XjWMP4ye\/","likes":{"count":0},"images":{"low_resolution":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpf1\/t51.2885-15\/s320x320\/e35\/12547507_218933238449715_1618422633_n.jpg","width":320,"height":320},"thumbnail":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpf1\/t51.2885-15\/s150x150\/e35\/12547507_218933238449715_1618422633_n.jpg","width":150,"height":150},"standard_resolution":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpf1\/t51.2885-15\/s640x640\/sh0.08\/e35\/12547507_218933238449715_1618422633_n.jpg","width":640,"height":640}},"users_in_photo":[],"caption":null,"user_has_liked":false,"id":"1168506212405185694_2231334066","user":{"username":"misery","profile_picture":"https:\/\/scontent.cdninstagram.com\/hphotos-xta1\/t51.2885-19\/10684024_538087799681202_2023427205_a.jpg","id":"2231334066","full_name":"misery"}},{"attribution":null,"tags":[],"type":"image","location":null,"comments":{"count":0},"filter":"Hefe","created_time":"1444533784","link":"https:\/\/www.instagram.com\/p\/8rpxxov48o\/","likes":{"count":2},"images":{"low_resolution":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpt1\/t51.2885-15\/s320x320\/e35\/11910259_421481191371212_1146964092_n.jpg","width":320,"height":320},"thumbnail":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpt1\/t51.2885-15\/s150x150\/e35\/11910259_421481191371212_1146964092_n.jpg","width":150,"height":150},"standard_resolution":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpt1\/t51.2885-15\/s640x640\/sh0.08\/e35\/11910259_421481191371212_1146964092_n.jpg","width":640,"height":640}},"users_in_photo":[],"caption":null,"user_has_liked":false,"id":"1093151075025784616_2231334066","user":{"username":"misery","profile_picture":"https:\/\/scontent.cdninstagram.com\/hphotos-xta1\/t51.2885-19\/10684024_538087799681202_2023427205_a.jpg","id":"2231334066","full_name":"misery"}}]}

回复内容:

$json的内容大概是这样的:

{"pagination":{},"meta":{"code":200},"data":[{"attribution":null,"tags":[],"type":"image","location":null,"comments":{"count":0},"filter":"Normal","created_time":"1453516817","link":"https:\/\/www.instagram.com\/p\/BA3XjWMP4ye\/","likes":{"count":0},"images":{"low_resolution":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpf1\/t51.2885-15\/s320x320\/e35\/12547507_218933238449715_1618422633_n.jpg","width":320,"height":320},"thumbnail":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpf1\/t51.2885-15\/s150x150\/e35\/12547507_218933238449715_1618422633_n.jpg","width":150,"height":150},"standard_resolution":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpf1\/t51.2885-15\/s640x640\/sh0.08\/e35\/12547507_218933238449715_1618422633_n.jpg","width":640,"height":640}},"users_in_photo":[],"caption":null,"user_has_liked":false,"id":"1168506212405185694_2231334066","user":{"username":"misery","profile_picture":"https:\/\/scontent.cdninstagram.com\/hphotos-xta1\/t51.2885-19\/10684024_538087799681202_2023427205_a.jpg","id":"2231334066","full_name":"misery"}},{"attribution":null,"tags":[],"type":"image","location":null,"comments":{"count":0},"filter":"Hefe","created_time":"1444533784","link":"https:\/\/www.instagram.com\/p\/8rpxxov48o\/","likes":{"count":2},"images":{"low_resolution":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpt1\/t51.2885-15\/s320x320\/e35\/11910259_421481191371212_1146964092_n.jpg","width":320,"height":320},"thumbnail":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpt1\/t51.2885-15\/s150x150\/e35\/11910259_421481191371212_1146964092_n.jpg","width":150,"height":150},"standard_resolution":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpt1\/t51.2885-15\/s640x640\/sh0.08\/e35\/11910259_421481191371212_1146964092_n.jpg","width":640,"height":640}},"users_in_photo":[],"caption":null,"user_has_liked":false,"id":"1093151075025784616_2231334066","user":{"username":"misery","profile_picture":"https:\/\/scontent.cdninstagram.com\/hphotos-xta1\/t51.2885-19\/10684024_538087799681202_2023427205_a.jpg","id":"2231334066","full_name":"misery"}}]}

转义而已,对自己问题的补充修改问题详情即可,不要发表在回答区域
这样解析json为什么没效果?

data;

foreach($data as $row){
    echo $row->images->standard_resolution->url."
"; }

你只用了json_decode来解码,但是输出的时候并没有json_encode啊。 输出的应该只是一堆字符串吧? \是用来转移字符的. \/ 其实输出以后就是/

相关标签: php