0

I am getting below output from a string, that I want to decode into a simple array so that I could use those value to process. web-service used below function to return response

echo(var_export($response));

Response

stdClass::__set_state(array(
   'criteriaKeyResultsMap' => 
  stdClass::__set_state(array(
     '477270310' => true,
     '528726710' => false,
     '517907210' => true,
     '497709910' => true,
     '253529610' => false,
     '529845410' => true,
     '519674810' => false,
     '517587110' => false,
     '477270610' => true,
     '260901310' => false,
     '260901610' => false,
     '529845110' => true,
  )),
))

I am trying with json_decode() but it gives same result.

2
  • How are you getting the string? It seems like there might be another problem here preventing an easier way of accessing the data. Commented Apr 12, 2016 at 4:36
  • API used echo(var_export($response)); to return result Commented Apr 12, 2016 at 5:00

2 Answers 2

1

The best fix will be to update your API (if you have control of the source) to use json_encode instead of var_export before it does an echo.

Parsing the output of var_export is possible, but a lot more complex, resource intensive and prone to breakage in the future.

Sign up to request clarification or add additional context in comments.

1 Comment

I don't have control to change in API.
0

Try this one

json_decode($your_data,true);

It will produce output .

3 Comments

$rst = json_decode($str); print_r($rst); this gives blank result
$rst = json_decode($str,true); add true .try this one
still getting blank response

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.