Skip to content

Commit

Permalink
added support for lists
Browse files Browse the repository at this point in the history
  • Loading branch information
aabssmc committed Jun 28, 2024
1 parent 969704f commit 9d80a9c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/lol/aabss/skhttp/objects/Json.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ public JsonElement add(String key, Object value, boolean skript){
return addProperty(key, value);
} else if (value == null){
return addProperty(key, null);
} else if (value instanceof Iterable<?>){
JsonArray array = new JsonArray();
for (Object object : (Iterable<?>) value){
if (Classes.getExactClassInfo(object.getClass()) != null && skript){
array.add(new Json(key, Classes.toString(object)).element);
} else {
array.add(new Json(key, gson.toJsonTree(object)).element);
}
}
if (element instanceof JsonObject) {
((JsonObject) element).add(key, array);
} else if (element instanceof JsonArray) {
((JsonArray) element).add(array);
}
} else {
if (Classes.getExactClassInfo(value.getClass()) != null && skript){
if (element instanceof JsonObject) {
Expand Down

0 comments on commit 9d80a9c

Please sign in to comment.