diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JSONUtil.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JSONUtil.java index 6b1046e94..75a4f7e0f 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JSONUtil.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JSONUtil.java @@ -1,6 +1,8 @@ package org.hl7.fhir.utilities.json; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; /*- * #%L @@ -68,4 +70,18 @@ public class JSONUtil { return null; } + public static String str(JsonObject json, String name) { + JsonElement e = json.get(name); + return e == null ? null : e.getAsString(); + } + + public static List objects(JsonObject json, String name) { + List res = new ArrayList<>(); + if (json.has(name)) + for (JsonElement e : json.getAsJsonArray(name)) + if (e instanceof JsonObject) + res.add((JsonObject) e); + return res; + } + }