Guest User

Untitled

a guest
Feb 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. public HashMap<String, Object> jsonToHashMap(JSONObject jsonObj)
  2. {
  3. HashMap<String, Object> hashRet = new HashMap<String, Object>();
  4.  
  5. String[] names = JSONObject.getNames(jsonObj);
  6.  
  7. for (String name : names)
  8. {
  9. try
  10. {
  11. hashRet.put(name, jsonObj.getInt(name));
  12. continue;
  13. }
  14. catch (Exception e)
  15. {
  16. }
  17.  
  18. try
  19. {
  20. hashRet.put(name, jsonObj.getString(name));
  21. continue;
  22. }
  23. catch (Exception e)
  24. {
  25. }
  26. }
  27.  
  28. return hashRet;
  29. }
Add Comment
Please, Sign In to add comment