use of org.hl7.fhir.r4b.formats.JsonCreatorGson in project org.hl7.fhir.core by hapifhir.
the class JsonParser method compose.
@Override
public void compose(Element e, OutputStream stream, OutputStyle style, String identity) throws FHIRException, IOException {
OutputStreamWriter osw = new OutputStreamWriter(stream, "UTF-8");
if (style == OutputStyle.CANONICAL)
json = new JsonCreatorCanonical(osw);
else
json = new JsonCreatorGson(osw);
json.setIndent(style == OutputStyle.PRETTY ? " " : "");
json.beginObject();
prop("resourceType", e.getType(), null);
Set<String> done = new HashSet<String>();
for (Element child : e.getChildren()) {
compose(e.getName(), e, done, child);
}
json.endObject();
json.finish();
osw.flush();
}
use of org.hl7.fhir.r4b.formats.JsonCreatorGson in project org.hl7.fhir.core by hapifhir.
the class JsonLDParser method compose.
@Override
public void compose(Element e, OutputStream stream, OutputStyle style, String base) throws IOException {
this.base = base;
OutputStreamWriter osw = new OutputStreamWriter(stream, "UTF-8");
if (style == OutputStyle.CANONICAL)
json = new JsonCreatorCanonical(osw);
else
json = new JsonCreatorGson(osw);
json.setIndent(style == OutputStyle.PRETTY ? " " : "");
json.beginObject();
prop("@type", "fhir:" + e.getType());
prop("@context", jsonLDBase + "fhir.jsonld");
prop("role", "fhir:treeRoot");
String id = e.getChildValue("id");
if (base != null && id != null) {
if (base.endsWith("#"))
prop("@id", base + e.getType() + "-" + id + ">");
else
prop("@id", Utilities.pathURL(base, e.getType(), id));
}
Set<String> done = new HashSet<String>();
for (Element child : e.getChildren()) {
compose(e.getName(), e, done, child);
}
json.endObject();
json.finish();
osw.flush();
}
use of org.hl7.fhir.r4b.formats.JsonCreatorGson in project org.hl7.fhir.core by hapifhir.
the class JsonLDParser method compose.
@Override
public void compose(Element e, OutputStream stream, OutputStyle style, String base) throws Exception {
this.base = base;
OutputStreamWriter osw = new OutputStreamWriter(stream, "UTF-8");
if (style == OutputStyle.CANONICAL)
json = new JsonCreatorCanonical(osw);
else
json = new JsonCreatorGson(osw);
json.setIndent(style == OutputStyle.PRETTY ? " " : "");
json.beginObject();
prop("@context", "http://hl7.org/fhir/jsonld/" + e.getType());
prop("resourceType", e.getType());
Set<String> done = new HashSet<String>();
for (Element child : e.getChildren()) {
compose(e.getName(), e, done, child);
}
json.endObject();
json.finish();
osw.flush();
}
use of org.hl7.fhir.r4b.formats.JsonCreatorGson in project org.hl7.fhir.core by hapifhir.
the class JsonParser method compose.
@Override
public void compose(Element e, OutputStream stream, OutputStyle style, String identity) throws Exception {
OutputStreamWriter osw = new OutputStreamWriter(stream, "UTF-8");
if (style == OutputStyle.CANONICAL)
json = new JsonCreatorCanonical(osw);
else
json = new JsonCreatorGson(osw);
json.setIndent(style == OutputStyle.PRETTY ? " " : "");
json.beginObject();
prop("resourceType", e.getType());
Set<String> done = new HashSet<String>();
for (Element child : e.getChildren()) {
compose(e.getName(), e, done, child);
}
json.endObject();
json.finish();
osw.flush();
}
use of org.hl7.fhir.r4b.formats.JsonCreatorGson in project org.hl7.fhir.core by hapifhir.
the class JsonParser method compose.
@Override
public void compose(Element e, OutputStream stream, OutputStyle style, String identity) throws FHIRException, IOException {
OutputStreamWriter osw = new OutputStreamWriter(stream, "UTF-8");
if (style == OutputStyle.CANONICAL)
json = new JsonCreatorCanonical(osw);
else
json = new JsonCreatorGson(osw);
json.setIndent(style == OutputStyle.PRETTY ? " " : "");
json.beginObject();
prop("resourceType", e.getType(), null);
Set<String> done = new HashSet<String>();
for (Element child : e.getChildren()) {
compose(e.getName(), e, done, child);
}
json.endObject();
json.finish();
osw.flush();
}
Aggregations