I am sending through some values from android/java to a server.
First I create a JSONArray object:
JSONArray JSONsamples = new JSONArray();
then I populate the JSONArray the following way:
for(.....)
{
if(...)
{
JSONsamples.put(storedArraylist.get(i));
}
}
Then I send the value through post :
userParameters.add(new BasicNameValuePair("samples", JSONsamples.toString()));
.
.
Http_Client.executeHttpPost(getApplicationContext(), POST_url, userParameters);
.
Then on the server I try to store those values into a php array, but it does not work:
$samplesarray = $_POST["samples"];
$samplesarray = json_decode($samplesarray,true);
Before decoding, If I echo $samplesarray , I only get the first value encapsulated in these \"value\" , after json_decode , when I echo $samplesarray I get a parameter expected but null found error.
Please help.
\"blood\"is whatJSONsamples.toString()returns. Or maybe it is"blood"if you have enabled magic_quotes. What is the expected return value ofJSONsamples.toString()?\"blood\"is not a valid JSON thats the problem I think.[]! it happens because you cannotjson_decodea string like\"blood\".JSONsamples.toString()should return something like this:["value1","value2","value3"]or{"key1":"value1","key2":"value2"}and you need to disable magic_quotes!