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
I still haven't figured out any solution without str_replace..
str_replace
Try this code.
$json_encoded_string = json_encode(...); $json_encoded_string = str_replace("\r", '\r', $json_encoded_string); $json_encoded_string = str_replace("\n", '\n', $json_encoded_string);
Hope that helps...