Guest User

Untitled

a guest
Jan 17th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. JSONObject json = new JSONObject();
  2.  
  3. try {
  4. json.put("CustomerID", "069C21F1-EE87-4FB4-A129-478AEAA454FF");
  5. json.put("Name", "Name_" + (int) Math.random() * 1000);
  6. } catch (JSONException e) {
  7. // TODO Auto-generated catch block
  8. e.printStackTrace();
  9. }
  10.  
  11. 1. prepare a LinkedHashMap object with elements
  12.  
  13. 2. convert it to JSONObject
  14.  
  15. Map obj = new LinkedHashMap();
  16. obj.put("a", "String1");
  17. obj.put("b", new Integer(1));
  18. obj.put("c", new Boolean(true));
  19. obj.put("d", "String2");
  20. JSONObject json = new JSONObject(obj);
  21.  
  22. public JSONObject(Map map)
Add Comment
Please, Sign In to add comment