My code using json_decode()
worked correctly with PHP 5.6. After migration to PHP 7.0, json_decode()
returns NULL and json_last_error()
tells me that my error is:
Control character error, possibly incorrectly encoded
After debugging, I found out that my problem are both tabs and new line characters in string values. If I remove them both, it works. If I leave either new lines or tabs, the error occurs.
Is json_decode()
behavior changed in PHP 7? I would like to keep tabs and new lines in my .json files for better readability. The code works if I replace tabs to \t and new lines to \n.
How can I keep new lines and tabs?