add to JsonUtil

This commit is contained in:
Grahame Grieve 2019-06-19 14:08:40 +10:00
parent a544140d2c
commit 3fc19f92bf
1 changed files with 11 additions and 0 deletions

View File

@ -76,6 +76,17 @@ public class JSONUtil {
return e == null ? null : e.getAsString();
}
public static String str(JsonObject json, String name1, String name2) {
JsonElement e = json.get(name1);
if (e == null)
e = json.get(name2);
return e == null ? null : e.getAsString();
}
public static boolean has(JsonObject json, String name1, String name2) {
return json.has(name1) || json.has(name2);
}
public static List<JsonObject> objects(JsonObject json, String name) {
List<JsonObject> res = new ArrayList<>();
if (json.has(name))