Code example for JsonArray

Methods: add

0
		a.addProperty("secret", "guest");
 
		JsonObject storage = new JsonObject();
		storage.addProperty("level", 3.212451f);
 
		JsonArray array = new JsonArray();
		array.add(new JsonPrimitive(1));
		array.add(new JsonPrimitive(2));
		array.add(new JsonPrimitive(3));
		storage.add("enemy", array);
 
		a.add("storage", storage);
 
		JsonElement newStorage = new Storage(a).create();
		// String id = 
		// newStorage.getAsJsonArray().get(0).getAsJsonObject().get("id").getAsString(); 
		String id = newStorage.getAsJsonObject().get("id").getAsString();
		log("Should create new storage"); 
		log(newStorage);
		log("should find it"); 
Contextual code suggestions in your IDE  Get Codota for Java