I have an JSON data in format of
[{"product_id":"33","amount":"1"},{"product_id":"34","amount":"3"},{"product_id":"10","amount":"1"},{"username":"test"}]
now I want to fetch those data in my PHP web system. I am sending those data into PHP server from an android application. I am using below code to send it to web server.
public JSONObject sendAndGetJSONfromURL(String url,List<NameValuePair> params){
InputStream is = null;
String result = "";
JSONObject jArray = null;
//http post
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
httppost.setHeader("Content-type", "application/json");
httppost.setHeader("Accept", "application/json");
httppost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
.....
Before send it I print the
jArray.toString()and got the output as
[{"product_id":"33","amount":"1"},{"product_id":"34","amount":"3"},{"product_id":"10","amount":"1"},{"username":"test"}]
I want to know that how can I fetch those values from PHP system. Can anyone please help me?
Output of the params variable value looks like below before sending via HTTPRequest
[cartdata=[{"product_id":"33","amount":"1"},{"product_id":"34","amount":"3"},{"product_id":"10","amount":"1"},{"username":"UWUDAMITH"}]]