For single pair value, I used:
datas.add(new BasicNameValuePair("latitude", Double.toString(lastKnownLocation.getLatitude())));
Then send it to server using HttpClient
:
HttpClient httpclient = CustomHttpClient.getHttpClient();
HttpPost httppost = new HttpPost(url);
httppost.setEntity(new UrlEncodedFormEntity(datas));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
input = entity.getContent();
At server side, I extract this information as follows:
$latitude = (_POST['latitude']);
But for an array of my own type, says Place
with 3 fields:
class Place {
int id;
String name;
String address;
}
How can I send this information to my php script? And within my php, how can I extract this JSON array?