Kevin.a Kevin.a - 1 year ago 133
JSON Question

Json_decode not functioning expecting array to be a string

Hello all im working with an API. From this In this API there's a lot of data. I'm trying to get a specific bit. Like this:

$SimplicateApi = new SimplicateApi('','key','secret');
$json = $SimplicateApi->makeApiCall('GET','/crm/person?q[first_name]=Kevin');
var_dump(json_decode($json, true));

I wanted to print the data decoded from the API.
I just want to print it on my web page to see if its working any other methods are okay with me too. as long i can see the data on my webpage.

Heres the error i got:

Warning: json_decode() expects parameter 1 to be string, array given
on line 361 NUL

Answer Source

You need to var_dump($json). The variable contains an array, not a JSON (json = string). I don't know SimplicateApi, but maybe the json you want is in the array returned by the makeApiCall method?

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