Re:New Features in PHP 5.6
by krapp on Friday January 17, 2014 @07:17PM
(#7079411)
If you look up the json_encode function on php.net it lists the flags. As I understand it there's a difference between the encoding allowed in javascript and the encoding allowed in JSON which means certain characters which would be valid in a javascript object don't necessarily work in JSON, so you end up having to escape everything possible. There's one flag (JSON_ESCAPE_UNICODE) which doesn't work on the version of PHP I develop on so I ended up applying code listed in the comments. This also adds some cruft similar to what google/facebook etc use if you want it. I haven't had any issues with it yet but, being what it is, there may be a more elegant way to accomplish it.
You might also consider looking at the ctype_* functions if you haven't.
[ Parent
| on HN ]
There are no comments on this comment yet.