我很难将 DistanceMatrix API 结果转换为 JSON 格式。
这是$response
(我在 Laravel 5.1 中使用 Ivory\googlempas 插件)的 var_dump
object(Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixResponse)#694 (4) { ["status":protected]=> string(2) "OK" ["destinations":protected]=> array(1) { [0]=> string(12) "Milan, Italy" } ["origins":protected]=> array(1) { [0]=> string(11) "Rome, Italy" } ["rows":protected]=> array(1) { [0]=> object(Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixResponseRow)#693 (1) { ["elements":protected]=> array(1) { [0]=> object(Ivory\GoogleMap\Services\DistanceMatrix\DistanceMatrixResponseElement)#692 (3) { ["status":protected]=> string(2) "OK" ["distance":protected]=> object(Ivory\GoogleMap\Services\Base\Distance)#690 (2) { ["text":protected]=> string(6) "572 km" ["value":protected]=> int(572343) } ["duration":protected]=> object(Ivory\GoogleMap\Services\Base\Duration)#691 (2) { ["text":protected]=> string(15) "5 hours 42 mins" ["value":protected]=> int(20517) } } } } } }
我如何在 JSON 数组中返回它?