json_decode('["foo","bar"]', true)
, this works, but this return NULL
, json_decode("['foo','bar']", true)
. The json_last_error()
outputs 4
, JSON_ERROR_SYNTAX
.
I've checked some answers from following questions;
json_decode() returns null issues
PHP json_decode() returns NULL with valid JSON?
json_decode returns NULL after webservice call
and tried following solutions but no success;
json_decode(str_replace('"', '"', "['foo','bar']"), true)
json_decode(stripslashes(str_replace('\"', '"', "['foo','bar']")), true)
json_decode(stripslashes("['foo','bar']"), true)
json_decode(utf8_encode("['foo','bar']"), true)
I don't think it has to do with UTF-8 bom. Is it a PHP bug? Or how do I do turn "['foo','bar']"
into '["foo","bar"]'
as a workaround?