From my android my PHP sever is receiving the below json :
{
"class":"SURESHOT",
"subject":"Maths",
"qstn":"[607421_15958169393.JPG, 410816_15958169444.JPG,
655502_15958169495.JPG, 625421_15958179086.JPG,
625421_15958179086.JPG, 461984_15958180457.JPG]",
"ans":"[C, B, A, D, C, C]",
"lickey":"jg2ler3xvbdgsjkru12tutujghgjgl4jkjojuir8uttzcdadasretf",
"user":"1000",
"result":"[fail,fail, pass, fail, fail, fail]",
"qid":"[37, 38, 39, 40, 40, 41]"
}
Now iterating through the data is not possible in PHP. 'qstn', 'ans' and 'result' are the problematic ones. How can we do it properly?
I used json_encode(($_POST),true); for preliminary data conversion.
This is the code I run to get the JSON:
This is the code from I get json.
reqPostanswers = new StringRequest(Request.Method.POST, urll,new Response.Listener<String>() {
@Override
public void onResponse(String response) {
//Log.i("posting info :",response.toString());
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
//Log.i("posting error :",error.toString());
}
}){
@Override
protected Map<String,String> getParams(){
Map<String,String> params = new HashMap<String, String>();
params.put("subject",subject);
params.put("class",qSet[qsetCntr][0]);
params.put("user", thisuser);
params.put("result",resltn.toString());
params.put("qstn",qstnn.toString());
params.put("qid", qiddn.toString());
params.put("ans",answn.toString());
params.put("lickey","jg2ler3xvbdgsjkru12tutujghgjgl4jkjojuir8uttzcdadasretf");
return params;
}
};
answerpostQueue = Volley.newRequestQueue(getApplicationContext());
answerpostQueue.add(reqPostanswers);
The arrays or variables in the prams set up is Arraylists only.