我正在製作一個應用程序,其中我從服務器端收到一個字符串作爲響應。該響應以json編碼。現在,我的問題是如何做編碼的響應的JSON解析從服務器端進行解碼.. 我從歌廳服務器以下響應android:json解析解碼
[「[email protected]」,「[email protected]」 ,「facebook_514728069」]
它是以數組的形式出現的。我想將其解碼並在我的另一個活動中顯示爲textviws。 我使用下面的代碼:
HttpClient client = new DefaultHttpClient();
String getURL = "http://www.ondamove.it/English/mob/profile_friends.php?email="+Login.eMailId+"";
HttpGet get = new HttpGet(getURL);
HttpResponse responseGet = client.execute(get);
HttpEntity resEntityGet = responseGet.getEntity();
if (resEntityGet != null)
{
String s = EntityUtils.toString(resEntityGet);
System.out.println(s);
JSONArray ids = new JSONArray(s);
for(int i=0; i< ids.length(); i++){
System.out.println(ids[]); //print each of the string in json array.
}
,但它給我的錯誤: 類型的表達式必須是一個數組類型,但它決心JSONArray
如何解決這個問題。 任何人都可以幫助我嗎? 謝謝
我該如何做到這一點我得到了服務器端的響應,我想說明一下 – ekjyot
你必須得到服務器響應作爲一個字符串對象「String jsonResponseString = Sever。的GetResponse();」那麼你可以按照上面的描述進行解析。 – hakansaglam