user2650277 user2650277 - 4 months ago 38
JSON Question

Convert json to array php gives Array to string conversion

I have a json as shown below.I want to access the value of

.However when i do
echo json_decode($json_response, true);
i get
Array to string conversion
.What is wrong here ?

"responses": [
"safeSearchAnnotation": {
"adult": "VERY_UNLIKELY",
"spoof": "VERY_UNLIKELY",
"medical": "UNLIKELY",
"violence": "LIKELY"


The function json_decode returns an array. You can't echo an array, or you'll get that conversion error.

You want to use print_r instead:

print_r(json_decode($json_response, true));

See here: