Posted By

ericpham on 09/25/14


Tagged

android


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

mannir


Gson Parser


 / Published in: Java
 

Need to import library first add jar file to libs then choose add as library

  1. public static JsonObject getData(String url)
  2. {
  3. HttpClient httpClient = new DefaultHttpClient();
  4. HttpPost httpPost = new HttpPost(url);
  5.  
  6. try
  7. {
  8. HttpResponse response = httpClient.execute(httpPost);
  9. String content = EntityUtils.toString(response.getEntity());
  10. Gson gson = new Gson();
  11. JsonObject jobj = new Gson().fromJson(content, JsonObject.class);
  12.  
  13. return jobj;
  14. }
  15. catch (Exception ex)
  16. {
  17. return null;
  18. }
  19. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: on September 27, 2018

sagemcom router software update micro888

You need to login to post a comment.