JSON PHP data has been obtained successfully but I am unable to access it -


I am using PHP to request an HTTP request from another web server to recover JSON data, The request works and I am able to use var_dump to see the data but I am unsure that I can access the data.

My code is for getting this data:

  $ response = request :: ($ mydetails) gets, $ Array1 = json_decode (json_encode ($ response) , This is the truth);  

I have tried almost everything (like $ array1-> operation-> result-> resonate status) gives me the same error message:

  PHP notice: trying to get non-object property  

This is the first few lines of var_dump output:

  array (9 ) {["Body"] = & gt; String (7017) "{" Operation ": {" Result ": {" Status ":" Success "," Message ":" The details of the request are listed successfully "}," Details ": [{" fields ": ["" Request "," value ":" event "," type ":" select list "," display value ":" request type "," permit number ": [" event "," request for change "," For "request", "request for work"], "mandatory": "wrong"}, {"name": "effect", "value": "affects user", "type" : "Select the list "," Performance value ":" effect "," acceptances ": [" affects business "," department affects "," affects group "," affects user "]," compulsory " ":" Status "," value "," wait "," type ":" select list "," display value ":" status "," permit number ": [" waiting The "customer", "wait for third party", "closed", "more information required", "impact", "value": "-", "type": "multi line", "payday" "Value": "phone call", "type": "", "value": "permission statement" "" "," mandatory ":" wrong "}, {" name ":" mode "," value " Select "list", "display value": "mode", "permit number": ["customer portal", "e-mail", "fax", "o-site request", "phone call"], "compulsory "" "" "," Value ":" seriousness 2 "," type ":" select list "," displayview ":" priority "," acceptance ": [" national level " 1 "," National Level 2 "," Request for Change "," Seriously "[" Name "": "department", "value": "general practice", "type 1", "seriousness 2", "seriousness 3", "seriousness 4"], "department", "acceptable" ":" Display value "" display name ":" requesteremail "," value ":" "," type ":" not editable "," display " Value ":" e-mail "," permit number ":" "," mandatory ":" false "}, {" name ":" requestcactactor "," value ":" "," type ":" not editable " ", The structure after a" displayview ""  
array So you should access it with array operator.

$ array1 ['body'] ['operation'] ['result'] ['status'] , Not -> - You can also interpret it as an object trashing operator:

  $ response = request: get ($ Mydetails); $ Array1 = json_decode (json_encode ($ response));  

But your response is already to be a array , then just access it without encoding again, maybe?

Edit: After making certain assumptions about your code, you should do this:

  $ response = Request :: Received Do ($ mydetails); $ Array1 = json_decode ($ response ['body'] is true); Var_dump ($ array1); // looks ok?  

Comments