try
{
HttpClient httpclient = new DefaultHttpClient();
HttpPost postMethod = new HttpPost("Insert JSON Url");
BufferedReader in = null;
BasicHttpResponse httpResponse = (BasicHttpResponse) httpclient.execute(postMethod);
in = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent()));
StringBuffer sb = new StringBuffer("");
String line = "";
while ((line = in.readLine()) != null)
{
sb.append(line);
}
in.close();
String result = sb.toString();
JSONObject resObject=new JSONObject(result);
String _key =resObject.getString("Insert Json Key");
Vector _adBeanVector = new Vector();
JSONArray newsArray = resObject.getJSONArray("Insert Json Array Key");
if(newsArray.length() > 0)
{
for (int i=0;
i < newsArray.length()
; i++)
{
Vector _adElementsVector=new Vector();
JSONObject newsObj = newsArray.getJSONObject(i);
_adElementsVector.addElement(newsObj.getString("Insert Json Array Element Key1"));
_adElementsVector.addElement(newsObj.getString("Insert Json Array Element Key2"));
_adBeanVector.addElement(_adElementsVector);
}
}
}
catch (Exception e)
{
}
{
HttpClient httpclient = new DefaultHttpClient();
HttpPost postMethod = new HttpPost("Insert JSON Url");
BufferedReader in = null;
BasicHttpResponse httpResponse = (BasicHttpResponse) httpclient.execute(postMethod);
in = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent()));
StringBuffer sb = new StringBuffer("");
String line = "";
while ((line = in.readLine()) != null)
{
sb.append(line);
}
in.close();
String result = sb.toString();
JSONObject resObject=new JSONObject(result);
String _key =resObject.getString("Insert Json Key");
Vector _adBeanVector = new Vector();
JSONArray newsArray = resObject.getJSONArray("Insert Json Array Key");
if(newsArray.length() > 0)
{
for (int i=0;
i < newsArray.length()
; i++)
{
Vector _adElementsVector=new Vector();
JSONObject newsObj = newsArray.getJSONObject(i);
_adElementsVector.addElement(newsObj.getString("Insert Json Array Element Key1"));
_adElementsVector.addElement(newsObj.getString("Insert Json Array Element Key2"));
_adBeanVector.addElement(_adElementsVector);
}
}
}
catch (Exception e)
{
}
1 comment:
nice one!
Post a Comment