php - 如何读取 json_decode 结果并转储它?
问题描述
我的 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
解决方案
查看此输出,看起来代码也存储在内容中。
“状态”:“好的”
因此,按照该方法的文档getData()
,您应该能够检索状态:
$data = $myVar->getData();
var_dump($data->status);
预计这将返回一个“ok”字符串。
推荐阅读
- android - RecyclerView 没有 LayoutManager | 科特林
- javascript - 当我在javascript中按下一个新字符时如何替换最后一个特殊字符
- flutter - Flutter web DevTools 网络选项卡丢失
- swift - RPBroadcastSampleHandler 无法使用 NotificationCenter 获取通知
- python - Python ValueError:所需数组的深度太小
- amazon-web-services - 如何更改为新的 AWS Cognito 用户池?
- mongodb - 用于修改数组字段的 Mongo 更新查询失败
- eclipse - maven项目中缺少java资源文件夹
- html - CSS div 大于其内部 div 的边框
- visualization - 如何使用 Tableau 使所有队列周从折线图中的 100% 标记开始?