Advertisement
ExploudYourEar

Qtor Shit

May 25th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. Disons que ta méthode qui va retourner ton string s'appelle makeHttpRequest
  2.  
  3. tu fais une méthode
  4. public JSONObject toJSONObject(String value)
  5. {
  6. try
  7. {
  8. JSONObject o = new JSONObject(value);
  9. }
  10. catch(Exception e)
  11. {
  12. JSONArray a = new JSONArray(value);
  13. JSONObject o = a.toJSONObject();
  14. }
  15. finally
  16. {
  17. return o;
  18. }
  19. }
  20.  
  21. et dans ton code tu peux faire
  22.  
  23. JSONObject monJSON = toJSONObject(makeHttpRequest());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement