[英]Laravel structuring JSON response
I am struggling to structure json response in Laravel, here's an example: 我正在努力在Laravel中构造json响应,这是一个示例:
{
"0": {
"instagram": [
{
"description": "#trainedacademy taking a break. We will resume for business on Monday 😎 @nickyjanew 🌞",
"time": "Wednesday 25th October",
"image": "https://scontent-lhr3-1.cdninstagram.com/t51.2885-15/s640x640/e15/22794071_716881718510905_8530561994892247040_n.jpg",
"likes": 15,
"comments": 0,
"link": "https://www.instagram.com/p/Baq437_FRav/",
"video": "https://scontent-lhr3-1.cdninstagram.com/t50.2886-16/22831768_291580031330276_8396013842173263872_n.mp4"
},
{
"description": "Jump into a #personaltraining #career! Started college and decided it’s not for you? Want to be a Gym Instructor? Circuit Trainer? Or work towards a career in the Fire Service? Join us Weds night for open enrolment or just get some careers advice from @paulalitherland and @nickyjanew \n@mahdloyouthzone 6:30pm Wednesday 8th November 2017. \nUCAS accredited \nindustry recognised \nExclusive discounts with the Fire Team badge \nFree food box @chiaproteinbar \nWork placements @thegymgroup",
"time": "Sunday 8th October",
"image": "https://scontent-lhr3-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/22277977_106714113419553_5412239854790508544_n.jpg",
"likes": 42,
"comments": 2,
"link": "https://www.instagram.com/p/BZ-WYZJloMY/",
"video": "https://scontent-lhr3-1.cdninstagram.com/t50.2886-16/22831768_291580031330276_8396013842173263872_n.mp4"
},
{
"description": "#trainedacademy #team @mahdloyouthzone preparing marketing material for 2018 enrolments. #oldhamfitness #oldham #practical #learningenhanced #alevels #employability @gymcareer @thegymgroup @chiaproteinbar",
"time": "Friday 6th October",
"image": "https://scontent-lhr3-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/22280199_2265489343466713_511544494877835264_n.jpg",
"likes": 50,
"comments": 0,
"link": "https://www.instagram.com/p/BZ5hLU6FRzr/",
"video": "https://scontent-lhr3-1.cdninstagram.com/t50.2886-16/22831768_291580031330276_8396013842173263872_n.mp4"
},
What I want to do is get rid of the "0": { part of the json. 我想做的就是摆脱“ 0”:{json的一部分。 Is that possible? 那可能吗?
return response()->json(['count' => $count_instagram, ['instagram' => $instagramArray ]], 200);
You have to use like this: 您必须这样使用:
return response()->json(['count' => $count_instagram, 'instagram' => $instagramArray ], 200);
Instead of 代替
return response()->json(['count' => $count_instagram, ['instagram' => $instagramArray ]], 200);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.