簡體   English   中英

如何讀取並轉儲json_decode結果?

[英]How to read a json_decode result and dump it?

我的json響應有點問題。

我將其轉儲到我的php代碼中,結果是我在此處附加的內容

如何轉儲statusText

我已經嘗試對其進行解碼,並且我也嘗試過此操作:

dump($myVar['statusText']);

或類似的東西

(要獲取我發布的json的轉儲,我剛剛做了dump($myVar);

JsonResponse {#325
  #data: "{"code":"OK","status":"ok","data":{"UUID":"f239ae18-98af-4224-8b4f-7713c71a5576","order":{something here },"orderRows":[something else here}}"
  #callback: null
  #encodingOptions: 271
  +headers: ResponseHeaderBag {#326
    #computedCacheControl: array:2 [
      "no-cache" => true
      "private" => true
    ]
    #cookies: []
    #headerNames: array:4 [
      "content-type" => "Content-Type"
      "access-control-allow-origin" => "Access-Control-Allow-Origin"
      "cache-control" => "Cache-Control"
      "date" => "Date"
    ]
    #headers: array:4 [
      "content-type" => array:1 [
        0 => "application/json; charset=utf-8"
      ]
      "access-control-allow-origin" => array:1 [
        0 => "*"
      ]
      "cache-control" => array:1 [
        0 => "no-cache, private"
      ]
      "date" => array:1 [
        0 => "Mon, 06 May 2019 08:15:28 GMT"
      ]
    ]
    #cacheControl: []
  }
  #content: "{"code":"OK","status":"ok","data":{"UUID":"f239ae18-98af-4224-8b4f-7713c71a5576","order":{something},"orderRows":[something else}}"
  #version: "1.0"
  #statusCode: 200
  #statusText: "OK"
  #charset: null
}

只是想看看"status" => 'ok' ,我的生活會很完美:D

查看此輸出,看起來代碼也存儲在內容中。

“狀態”: “OK”

因此,按照此文檔中的getData()方法,您應該能夠檢索狀態:

$data = $myVar->getData();
var_dump($data->status);

預期這將返回字符串“ ok”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM