Merge pull request #35 from vadi2/master
Serialise -output as json if the filename ends on ".json"
This commit is contained in:
commit
74b9488ffc
|
@ -62,8 +62,10 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hl7.fhir.r5.conformance.ProfileComparer;
|
import org.hl7.fhir.r5.conformance.ProfileComparer;
|
||||||
|
import org.hl7.fhir.r5.formats.IParser;
|
||||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||||
import org.hl7.fhir.r5.formats.XmlParser;
|
import org.hl7.fhir.r5.formats.XmlParser;
|
||||||
|
import org.hl7.fhir.r5.formats.JsonParser;
|
||||||
import org.hl7.fhir.r5.model.Bundle;
|
import org.hl7.fhir.r5.model.Bundle;
|
||||||
import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent;
|
import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent;
|
||||||
import org.hl7.fhir.r5.model.Constants;
|
import org.hl7.fhir.r5.model.Constants;
|
||||||
|
@ -377,7 +379,13 @@ public class Validator {
|
||||||
validator.setHintAboutNonMustSupport(hintAboutNonMustSupport);
|
validator.setHintAboutNonMustSupport(hintAboutNonMustSupport);
|
||||||
validator.setAnyExtensionsAllowed(anyExtensionsAllowed);
|
validator.setAnyExtensionsAllowed(anyExtensionsAllowed);
|
||||||
|
|
||||||
XmlParser x = new XmlParser();
|
IParser x;
|
||||||
|
if (output != null && output.endsWith(".json"))
|
||||||
|
x = new JsonParser();
|
||||||
|
else
|
||||||
|
x = new XmlParser();
|
||||||
|
x.setOutputStyle(OutputStyle.PRETTY);
|
||||||
|
|
||||||
if (mode == EngineMode.TRANSFORM) {
|
if (mode == EngineMode.TRANSFORM) {
|
||||||
if (sources.size() > 1)
|
if (sources.size() > 1)
|
||||||
throw new Exception("Can only have one source when doing a transform (found "+sources+")");
|
throw new Exception("Can only have one source when doing a transform (found "+sources+")");
|
||||||
|
@ -391,8 +399,7 @@ public class Validator {
|
||||||
System.out.println(" ...success");
|
System.out.println(" ...success");
|
||||||
if (output != null) {
|
if (output != null) {
|
||||||
FileOutputStream s = new FileOutputStream(output);
|
FileOutputStream s = new FileOutputStream(output);
|
||||||
x.setOutputStyle(OutputStyle.PRETTY);
|
x.compose(s, r);
|
||||||
x.compose(s, r, true);
|
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -434,7 +441,7 @@ public class Validator {
|
||||||
displayOO((OperationOutcome)r);
|
displayOO((OperationOutcome)r);
|
||||||
} else {
|
} else {
|
||||||
FileOutputStream s = new FileOutputStream(output);
|
FileOutputStream s = new FileOutputStream(output);
|
||||||
x.compose(s, r, true);
|
x.compose(s, r);
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue