有一个JsonResponse数据的格式如下:
object(IlluminateHttpJsonResponse)[474] protected 'data' => string '{"code":200,"message":"u6210u529f","data":{"file_name":"b3c8622cc85a5783b6b39e6c998f8c1e.jpg","file_path":"b3/c8/b3c8622cc85a5783b6b39e6c998f8c1e.jpg","file_size":290576,"url":"https://quxuexi-pub.qfq.me/b3/c8/b3c8622cc85a5783b6b39e6c998f8c1e.jpg","original_url":"/tmp/phpUVwzdV"}}' (length=292) protected 'callback' => null protected 'encodingOptions' => int 0 public 'headers' => object(SymfonyComponentHttpFoundationResponseHeaderBag)[476] protected 'computedCacheControl' => array (size=2) 'no-cache' => boolean true 'private' => boolean true protected 'cookies' => array (size=0) empty protected 'headerNames' => array (size=3) 'cache-control' => string 'Cache-Control' (length=13) 'date' => string 'Date' (length=4) 'content-type' => string 'Content-Type' (length=12) protected 'headers' => array (size=3) 'cache-control' => array (size=1) ... 'date' => array (size=1) ... 'content-type' => array (size=1) ... protected 'cacheControl' => array (size=0) empty protected 'content' => string '{"code":200,"message":"u6210u529f","data":{"file_name":"b3c8622cc85a5783b6b39e6c998f8c1e.jpg","file_path":"b3/c8/b3c8622cc85a5783b6b39e6c998f8c1e.jpg","file_size":290576,"url":"https://quxuexi-pub.qfq.me/b3/c8/b3c8622cc85a5783b6b39e6c998f8c1e.jpg","original_url":"/tmp/phpUVwzdV"}}' (length=292) protected 'version' => string '1.0' (length=3) protected 'statusCode' => int 200 protected 'statusText' => string 'OK' (length=2) protected 'charset' => null public 'original' => array (size=3) 'code' => int 200 'message' => string '鎴愬姛' (length=6) 'data' => array (size=5) 'file_name' => string 'b3c8622cc85a5783b6b39e6c998f8c1e.jpg' (length=36) 'file_path' => string 'b3/c8/b3c8622cc85a5783b6b39e6c998f8c1e.jpg' (length=42) 'file_size' => int 290576 'url' => string 'https://quxuexi-pub.qfq.me/b3/c8/b3c8622cc85a5783b6b39e6c998f8c1e.jpg' (length=69) 'original_url' => string '/tmp/phpUVwzdV' (length=14) public 'exception' => null
想要获取其中的data数据,然后就直接:
$result['data'];
最后发现这是不可以的,正确的方法如下:
$jsonArray = $result->getData(true);