Posted By

nialace on 01/27/11


Tagged

java json


Versions (?)

JSON


 / Published in: Java
 

json avec gson (google)

  1. JsonObject json = new JsonObject();
  2. json.addProperty("AD_GROUPS", "Utilisateurs");
  3. json.addProperty("AD_QUOTA", "1000");
  4.  
  5. System.out.println(json);
  6.  
  7. JsonParser parser = new JsonParser();
  8. JsonElement el = parser.parse(json.toString());
  9. JsonObject test = el.getAsJsonObject();
  10.  
  11. Set set = test.entrySet();
  12.  
  13. for (Iterator iterator = set.iterator(); iterator.hasNext();) {
  14. Map.Entry<String, JsonElement> mapEntry = (Map.Entry<String, JsonElement>) iterator.next();
  15. System.out.println(mapEntry.getKey()+" "+mapEntry.getValue().getAsString());
  16. }

Report this snippet  

You need to login to post a comment.