從服務請求中,我得到以下響應,我嘗試使用json_decode
解析它,但它不起作用。我需要檢查 ["body"]->enquiry->status
是否「打開」。任何人都可以告訴我如何解析這個迴應?使用PHP解析JSON數組不起作用
array(5) {
["headers"] => array(5) {
["server"] => string(17)
"Apache-Coyote/1.1" ["content-type"] => string(16)
"application/json" ["content-length"] => string(3)
"313" ["date"] => string(29)
"Fri, 08 Jul 2016 00:22:29 GMT" ["connection"] => string(5)
"close"
}
["body"] => string(313){
"version ":{
"major ":1,
"minor ":6,
"revision ":0
},
"enquiry ":{
"id ":"21a2a688-c09b-48bc-8cb0-0ad596c18447",
"creationTime ":1467937344745,
"lastUpdateTime ":1467937344753,
"status ":"OPEN ",
"from ":"test ",
"email ":"[email protected] ",
"message ":"test ",
},
"enquiries":null
}
["response"] => array(2) {
["code"] => int(202)
["message"] => string(8)
"Accepted"
}
["cookies"] => array(0) {}
["filename"] => NULL
}
剛剛訪問相應的索引,JSON字符串與陣列標誌進行解碼,然後把它像任何正常陣列 – Ghost
上面的代碼是響應或與json_decode響應解碼?我想看到原始的迴應。 –
這是我從服務中獲得的原始響應。我實際上是PHP新手,非常感謝任何幫助。 – user3736514