user2650277 user2650277 - 1 year ago 116
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"

Answer Source

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:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download