I wanted to know how to convert the http response from the server in a proper parsable JSON array
try {
HttpClient httpClient = new DefaultHttpClient();
HttpPost postRequest = new HttpPost(
"http://riffre.com/chatapp/search.php?format=json");
postRequest.setEntity(new UrlEncodedFormEntity(nameValuePair));
ResponseHandler<String> responseHandler = new BasicResponseHandler();
responsesrch = httpClient.execute(postRequest, responseHandler);
Log.v("search response", responsesrch);
this is my code where I post a few parameters in form of name value pairs to the server
and the value of responseserch that I get is
{"users":[{"user":{"city":"gurgaon","username":"zxc","userid":"6","gender":"Male","images":"0"}},{"user":{"city":"gurgaon","username":"tarun","userid":"5","gender":"Male","images":"0"}},{"user":{"city":"gurgaon","username":"vips","userid":"4","gender":"Male","images":"0"}},{"user":{"city":"gurgaon","username":"rah","userid":"3","gender":"Male","images":"0"}},{"user":{"city":"gurgaon","username":"aak","userid":"2","gender":"Male","images":"0"}}]}
and this is in string format ,So I wanted to know how can I convert this string into a json array , I don’t know yet how I must use Input stream and all those entities, Any help therefore would be greatly appreciated.
please look this , it is simple
http://www.androidhive.info/2012/01/android-json-parsing-tutorial/
convert IS to String
convert String to Json Object
get Array from Object