diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java index 071676dc8..f074cb611 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java @@ -19,12 +19,11 @@ import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule; import org.hl7.fhir.r5.model.UriType; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.VersionUtilities; -import org.hl7.fhir.utilities.json.JsonTrackingParser; +import org.hl7.fhir.utilities.json.model.JsonElement; +import org.hl7.fhir.utilities.json.model.JsonObject; +import org.hl7.fhir.utilities.json.parser.JsonParser; import org.hl7.fhir.utilities.npm.PackageHacker; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - public class XVerExtensionManager { public enum XVerExtensionStatus { @@ -54,7 +53,7 @@ public class XVerExtensionManager { if (!lists.containsKey(v)) { if (context.hasBinaryKey("xver-paths-"+v+".json")) { try { - lists.put(v, JsonTrackingParser.parseJson(context.getBinaryForKey("xver-paths-"+v+".json"))); + lists.put(v, JsonParser.parseObject(context.getBinaryForKey("xver-paths-"+v+".json"))); } catch (IOException e1) { throw new FHIRException(e); } @@ -63,9 +62,9 @@ public class XVerExtensionManager { } } JsonObject root = lists.get(v); - JsonObject path = root.getAsJsonObject(e); + JsonObject path = root.getObj(e); if (path == null) { - path = root.getAsJsonObject(e+"[x]"); + path = root.getObj(e+"[x]"); } if (path == null) { return XVerExtensionStatus.Unknown; @@ -86,9 +85,9 @@ public class XVerExtensionManager { String verTarget = VersionUtilities.getMajMin(context.getVersion()); String e = url.substring(54); JsonObject root = lists.get(verSource); - JsonObject path = root.getAsJsonObject(e); + JsonObject path = root.getObj(e); if (path == null) { - path = root.getAsJsonObject(e+"[x]"); + path = root.getObj(e+"[x]"); } StructureDefinition sd = new StructureDefinition(); @@ -116,10 +115,10 @@ public class XVerExtensionManager { ElementDefinition val = sd.getDifferential().addElement().setPath("Extension.value[x]").setMin(1); populateTypes(path, val, verSource, verTarget); } else if (path.has("elements")) { - for (JsonElement i : path.getAsJsonArray("elements")) { - JsonObject elt = root.getAsJsonObject(e+"."+i.getAsString()); + for (JsonElement i : path.getArr("elements").getItems()) { + JsonObject elt = root.getObj(e+"."+i.toString()); if (elt != null) { - String s = i.getAsString().replace("[x]", ""); + String s = i.toString().replace("[x]", ""); sd.getDifferential().addElement().setPath("Extension.extension").setSliceName(s); sd.getDifferential().addElement().setPath("Extension.extension.extension").setMax("0"); sd.getDifferential().addElement().setPath("Extension.extension.url").setFixed(new UriType(s)); @@ -135,7 +134,7 @@ public class XVerExtensionManager { } else { throw new FHIRException("Internal error - attempt to define extension for "+url+" when it is invalid"); } - if (path.has("modifier") && path.get("modifier").getAsBoolean()) { + if (path.has("modifier") && path.getBoolean("modifier")) { ElementDefinition baseDef = new ElementDefinition("Extension"); sd.getDifferential().getElement().add(0, baseDef); baseDef.setIsModifier(true); @@ -144,8 +143,8 @@ public class XVerExtensionManager { } public void populateTypes(JsonObject path, ElementDefinition val, String verSource, String verTarget) { - for (JsonElement i : path.getAsJsonArray("types")) { - String s = i.getAsString(); + for (JsonElement i : path.getArr("types").getItems()) { + String s = i.toString(); if (!s.startsWith("!")) { if (s.contains("(")) { String t = s.substring(0, s.indexOf("(")); diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JsonException.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JsonException.java index beaba2163..026b89e28 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JsonException.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JsonException.java @@ -1,6 +1,8 @@ package org.hl7.fhir.utilities.json; -public class JsonException extends Exception { +import org.hl7.fhir.exceptions.FHIRException; + +public class JsonException extends FHIRException { public JsonException(String msg) { // TODO Auto-generated constructor stub diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/model/JsonObject.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/model/JsonObject.java index 1acd3228a..0c6fb3fff 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/model/JsonObject.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/model/JsonObject.java @@ -106,7 +106,7 @@ public class JsonObject extends JsonElement { } public Boolean getBoolean(String name) { - return ((JsonBoolean) get(name)).isValue(); + return has(name) ? ((JsonBoolean) get(name)).isValue() : false; } public JsonObject forceObj(String name) throws JsonException { diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/parser/JsonParser.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/parser/JsonParser.java index 5d9a65455..a6fbb5b3c 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/parser/JsonParser.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/parser/JsonParser.java @@ -38,6 +38,8 @@ import org.hl7.fhir.utilities.json.parser.JsonLexer.TokenType; * * missing commas in objects and arrays * * comments - anything starting // will be processed as a comma to the end of the line * + * Other JSON5 features might be added in the future + * * The FHIR Validator uses this parser in Json5 mode, and the object model is marked up * with deviations from base JSON spec so that the validator can record them as errors * (this is better than blowing up parsing the JSON) diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java index b3c1eedd5..3c5c5985a 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java @@ -5787,7 +5787,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat slicingHint(errors, IssueType.INFORMATIONAL, ei.line(), ei.col(), ei.getPath(), false, isProfile(slicer) || isCritical(ei.sliceInfo), context.formatMessage(I18nConstants.THIS_ELEMENT_DOES_NOT_MATCH_ANY_KNOWN_SLICE_, profile == null ? "" : "defined in the profile " + profile.getVersionedUrl()), - context.formatMessage(I18nConstants.THIS_ELEMENT_DOES_NOT_MATCH_ANY_KNOWN_SLICE_, profile == null ? "" : I18nConstants.DEFINED_IN_THE_PROFILE + profile.getVersionedUrl()) + errorSummaryForSlicingAsHtml(ei.sliceInfo), + context.formatMessage(I18nConstants.THIS_ELEMENT_DOES_NOT_MATCH_ANY_KNOWN_SLICE_, profile == null ? "" : context.formatMessage(I18nConstants.DEFINED_IN_THE_PROFILE) + " "+profile.getVersionedUrl()) + errorSummaryForSlicingAsHtml(ei.sliceInfo), errorSummaryForSlicingAsText(ei.sliceInfo)); } else if (ei.definition.getSlicing().getRules().equals(ElementDefinition.SlicingRules.CLOSED)) { rule(errors, IssueType.INVALID, ei.line(), ei.col(), ei.getPath(), false, I18nConstants.VALIDATION_VAL_PROFILE_NOTSLICE, (profile == null ? "" : " defined in the profile " + profile.getVersionedUrl()), errorSummaryForSlicing(ei.sliceInfo)); diff --git a/pom.xml b/pom.xml index c8c2fbbac..bfd8b8e26 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 5.4.0 - 1.1.123-SNAPSHOT + 1.1.123 5.7.1 1.8.2 3.0.0-M5