I am decoding/parsing JSON over http fetch and on android I get null results, while on a browser I get the following, which is valid JSON format:
[
{
"KEY": "-2.71208569845,-1.46780473499, ..."
}
]
where the array is a long list of double values I store as a medium blob in a mysql db. In android, I get this no matter what I try:
[{"KEY":""}]
I've tried changing between httpget and httppost, and looked at may other posts on SO and tried their suggestions, to no avail. Here is the PHP:
<snip>
mysql_query('SET CHARACTER SET utf8');
$result=mysql_query("SELECT avgfftspectrum FROM `TremCamTbl` WHERE
email='".$_REQUEST['email']."'
ORDER BY subjectid DESC LIMIT 1");
if (mysql_num_rows($result) > 0) {
//$response["KEY"] = array();
while ($row = mysql_fetch_assoc($result)) {
$fftdata[] = array_map('utf8_encode', $row);
/*$data = $row["avgfftspectrum"]; I have also tried these two lines
**array_push($response["KEY"], $data); */
}
echo json_encode($fftdata);
}
<snip>
My android HttpPost or HttpGet look more or less like:
<snip>
String paramString = URLEncodedUtils.format(nameValuePairs, "utf-8");
HttpPost httpPost = new HttpPost(WebConstants.getCloudavgfftUrl()+"?"+paramString);
Log.i(TAG, ""+WebConstants.getCloudavgfftUrl()+"?"+paramString);
try {
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String responseBody = httpClient.execute(httpPost,responseHandler);
Log.i(TAG, ""+responseBody.length());
// Parse
JSONArray jArray = new JSONArray(responseBody);
Log.i(TAG, ""+jArray.length());
Log.i(TAG, ""+jArray.toString());
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
<snip>
Any suggestions on what I am doing wrong?