I am returning some SQL results from PHP to android.
I encode the JSON response as follows:
$json_string = json_encode($rows);
$json_string = str_replace("\\", "", $json_string, $i);
return $json_string;
Once i echo this back to android i get a string which when I place into a JSON validator gives valid JSON code.
HOWEVER....once i try to pass this valid string into a new JSONObject or JSONArray I receive an error that it cannot be converted.
I am sure that this is because of whitespace invisible characters.
I have encoded both my PHP and Java in utf-8 character set using the following in Java...
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "utf-8"), 8);
and for PHP...
header('Content-Type: text/html; charset=utf-8');
but this has not solved the problem.
Any help greatly appreciated.