From 6ea5016da55723f775c0112b4bed0621f9f78c22 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 12 Feb 2020 17:45:32 +1100 Subject: [PATCH] fix JsonUtils to handle null --- .../src/main/java/org/hl7/fhir/utilities/json/JSONUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 346f319e6..301574ea7 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 @@ -28,6 +28,7 @@ import java.util.Map.Entry; import com.google.gson.JsonArray; import com.google.gson.JsonElement; +import com.google.gson.JsonNull; import com.google.gson.JsonObject; public class JSONUtil { @@ -73,7 +74,7 @@ public class JSONUtil { public static String str(JsonObject json, String name) { JsonElement e = json.get(name); - return e == null ? null : e.getAsString(); + return e == null || e instanceof JsonNull ? null : e.getAsString(); } public static String str(JsonObject json, String name1, String name2) {