Search in sources :

Example 1 with JsonTrackingParser

use of org.hl7.fhir.utilities.json.JsonTrackingParser in project org.hl7.fhir.core by hapifhir.

the class CorePackageTools method buildXml.

private void buildXml(String json, String xml, String version) throws FHIRFormatError, IOException {
    for (File f : new File(Utilities.path(json, "package")).listFiles()) {
        if (f.getName().endsWith(".json")) {
            JsonObject j = new JsonTrackingParser().parseJson(f);
            if (j.has("resourceType")) {
                if ("1.4".equals(version)) {
                    String n = f.getName();
                    System.out.println(n);
                    String xn = Utilities.changeFileExt(n, ".xml");
                    org.hl7.fhir.dstu2016may.model.Resource r = new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(new FileInputStream(f));
                    new org.hl7.fhir.dstu2016may.formats.XmlParser().setOutputStyle(org.hl7.fhir.dstu2016may.formats.IParser.OutputStyle.NORMAL).compose(new FileOutputStream(Utilities.path(xml, "package", xn)), r);
                }
            }
        }
    }
}
Also used : JsonObject(com.google.gson.JsonObject) JsonTrackingParser(org.hl7.fhir.utilities.json.JsonTrackingParser) FileInputStream(java.io.FileInputStream) FileOutputStream(java.io.FileOutputStream) File(java.io.File)

Aggregations

JsonObject (com.google.gson.JsonObject)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 JsonTrackingParser (org.hl7.fhir.utilities.json.JsonTrackingParser)1