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);
  • 相关阅读:
    光棍节奉献10款chart插件 节日快乐.
    平安夜分享2款下拉菜单(CSS版本和JQuery版本)
    MVC 中T4扫盲贴
    解析JQuery 的Bind()事件
    Null在从数据库读取的时候的一点点小阴谋
    JQuery 动画效果集锦
    VS2010支持的6款UML简介
    T4系列文章之2:T4工具简介、调试以及T4运行原理
    既然结构也可以继承接口
    css float 之 clear
  • 原文地址:https://www.cnblogs.com/cjjjj/p/9991989.html
Copyright © 2011-2022 走看看