サーバーからの http 応答を適切な解析可能な JSON 配列に変換する方法を知りたかった
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);
これは私のコードで、名前と値のペアの形式でいくつかのパラメーターをサーバーに投稿し、responseserch
取得した値は次のとおりです
{"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"}}]}
これは文字列形式なので、この文字列を json 配列に変換する方法を知りたかったのですが、入力ストリームとこれらすべてのエンティティをどのように使用する必要があるかまだわかりません。