Reputation: 12608
I have built a very simple Python
API
using flask
, my response looks like this...
response = {
"id" : "345345d",
"topdata" : {
"top" : 234,
"left" : 42,
},
"bottomdata" : {
"color" : "red",
"bg" : "black",
},
}
return jsonify(response)
I then try and decode that response in my PHP script like this...
$response = json_decode($response);
But this gives me the following error..
Cannot use object of type stdClass as array
Anyone any ideas where I am going wrong?
Upvotes: 0
Views: 173
Reputation: 1425
json_decode has a 2nd argument to return an array:
$response = json_decode($response, true);
Upvotes: 1