从API服务解码JSON重试问题

问题描述 投票:0回答:1

我在使用Laravel 6下的Guzzle 6时从Web服务中分​​解JSON响应时遇到问题,

我尝试解码的响应在这里:

https://json.volotea.com/dist/stations/stations.json

在我的PHP代码中,我以这种方式尝试:

$client = new Client();

$response = $client->request('GET','https://json.volotea.com/dist/stations/stations.json');

为了解码响应,我尝试了几种方法,例如:

$response->getBody();  // that returns a stream

$response->getBody()->getContents(); that returns an apparently correct answer but if I run the json_decode it returns a null as a result

我快疯了!

我如何解码此服务的响应?

非常感谢

php json php-7 guzzle guzzle6
1个回答
0
投票

似乎通过getContent方法,您已经操纵了Json结构在$ response上尝试json_decode。

© www.soinside.com 2019 - 2024. All rights reserved.