Does anyone know why this happens?
var_dump(json_decode(stripslashes(json_encode(array("O'Reiley"))))); // array(1) { [0]=> string(8) "O'Reiley" }
var_dump(json_decode(stripslashes(json_encode(array("O\'Reiley"))))); // NULL
Are ' used at all by the JSON functions?
I don’t know for sure, but json_last_error() should 🙂
My guess, though, is that
json_encode()does something to the\'that thestripslashes()then breaks – e.g. add another “\” to escape the backslash.Isn’t fiddling with a json encoded string using
striplslashes()before it’s decoded wrong anyway?