zoukankan      html  css  js  c++  java
  • Laravel JsonResponse数组获取

    有一个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);
  • 相关阅读:
    day23_雷神_git
    day23_雷神_crm-day2
    day21_雷神_django第四天
    day20_雷神_django第三天
    day19_雷神_django第二天
    day18_雷神_django第一天
    day17_雷神_数据库 小全
    day16_雷神_前端04
    awksedgrep 补充
    python 操作MongoDB非关系型数据库
  • 原文地址:https://www.cnblogs.com/cjjjj/p/9991989.html
Copyright © 2011-2022 走看看