http://www.taxmann.com/TaxmannWhatsnewService/Services.aspx?service=getStatutesTabNewsJson Parsin in android
이것은 내 웹 서비스입니다. 나는 그것을 분석하고 나는 show_id와 news title을 보여주고 싶다. 게시하여, 모든 값을 문자열에 저장할 수 있도록 파싱하는 방법을 보여주십시오. 나는 시도했지만 여전히 결과를 얻을 수없는 경우 코드 아래 사용할 수 있습니다 Exception ..
try
{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.taxmann.com/TaxmannWhatsnewService/Services.aspx?service=getStatutesTabNews");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch(Exception e)
{
Log.e("log_tag", "Error in http connection"+e.toString());
}
//convert response to string
try
{
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"UTF-8"),8);
sb = new StringBuilder();
sb.append(reader.readLine() + "\n");
String line="0";
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
is.close();
result=sb.toString();
}catch(Exception e)
{
Log.e("log_tag", "Error converting result "+e.toString());
}
// String name;
try
{
jArray = new JSONArray(result);
JSONObject json_data=null;
for(int i=0;i<jArray.length();i++)
{
HashMap<String, String> map = new HashMap<String, String>();
json_data = jArray.getJSONObject(i);
// name=json_data.getString("name");
map.put("id", String.valueOf(json_data.getString("news_id")));
map.put("title",json_data.getString("news_title"));
map.put("shortdescription",json_data.getString("news_short_description"));
map.put("date",json_data.getString("news_date"));
mylist.add(map);
}
}
catch(Exception e)
{
}
}
는 – Herry
은 또한 당신이 여기 JSON 문자열을 넣을 수 있습니다 도움이 될 수 있습니다 귀하의 질문에 예외를 보여줍니다. – Herry
http://www.taxmann.com/TaxmannWhatsnewService/Services.aspx?service=getStatutesTabNews –