Is there any reasons why PHP\'s json_encode function does not escape all JSON control characters in a string?
For example let\'s take a string which spans two rows a
$search = array("\n", "\r", "\u", "\t", "\f", "\b", "/", '"'); $replace = array("\\n", "\\r", "\\u", "\\t", "\\f", "\\b", "\/", "\""); $encoded_string = str_replace($search, $replace, $json);
This is the correct way