json_decode returns NULL (php)
Posted
by schouk
on Stack Overflow
See other posts from Stack Overflow
or by schouk
Published on 2009-03-27T10:11:48Z
Indexed on
2010/05/31
0:02 UTC
Read the original article
Hit count: 528
There is a strange behaviour with json_encode
and json_decode
and I can't find a solution:
My php application calls a php web service. The webservice returns json that looks like this:
var_dump($foo):
string(62) "?{"action":"set","user":"123123123123","status":"OK"}"
now I like to decode the json in my application:
$data = json_decode($foo, true)
but it returns NULL:
var_dump($data):
NULL
I use php 5.
The Content-Type of the response from the webservice: "text/html; charset=utf-8"
(also tried to use "application/json; charset=utf-8"
)
What could be the reason?
© Stack Overflow or respective owner