Exemple #1
0
 public JsonArray add(Object obj) {
   checkCopy();
   if (obj instanceof JsonObject) {
     obj = ((JsonObject) obj).map;
   } else if (obj instanceof JsonArray) {
     obj = ((JsonArray) obj).list;
   }
   list.add(obj);
   return this;
 }
Exemple #2
0
 @SuppressWarnings("unchecked")
 static List<Object> convertList(List<?> list) {
   List<Object> arr = new ArrayList<>(list.size());
   for (Object obj : list) {
     if (obj instanceof Map) {
       arr.add(JsonObject.convertMap((Map<String, Object>) obj));
     } else if (obj instanceof JsonObject) {
       arr.add(((JsonObject) obj).toMap());
     } else if (obj instanceof List) {
       arr.add(convertList((List<?>) obj));
     } else {
       arr.add(obj);
     }
   }
   return arr;
 }
Exemple #3
0
 public JsonArray addBinary(byte[] value) {
   checkCopy();
   String encoded = org.vertx.java.core.json.impl.Base64.encodeBytes(value);
   list.add(encoded);
   return this;
 }
Exemple #4
0
 public JsonArray addBoolean(Boolean value) {
   checkCopy();
   list.add(value);
   return this;
 }
Exemple #5
0
 public JsonArray addNumber(Number value) {
   checkCopy();
   list.add(value);
   return this;
 }
Exemple #6
0
 public JsonArray addArray(JsonArray value) {
   checkCopy();
   list.add(value.list);
   return this;
 }
Exemple #7
0
 public JsonArray addObject(JsonObject value) {
   checkCopy();
   list.add(value.map);
   return this;
 }
Exemple #8
0
 public JsonArray addString(String str) {
   checkCopy();
   list.add(str);
   return this;
 }
Exemple #9
0
 public boolean contains(Object value) {
   return list.contains(value);
 }
Exemple #10
0
 public <T> T get(final int index) {
   return convertObject(list.get(index));
 }
Exemple #11
0
 public int size() {
   return list.size();
 }