Fixed UTF-8 bug
Add json_encode error checking