use of org.hl7.fhir.utilities.json.JsonTrackingParser.LocationData in project org.hl7.fhir.core by hapifhir.
the class JsonParser method parse.
@Override
public Element parse(InputStream stream) throws IOException, FHIRFormatError, DefinitionException {
// if we're parsing at this point, then we're going to use the custom parser
map = new HashMap<JsonElement, LocationData>();
String source = TextFile.streamToString(stream);
if (policy == ValidationPolicy.EVERYTHING) {
JsonObject obj = null;
try {
obj = JsonTrackingParser.parse(source, map);
} catch (Exception e) {
logError(-1, -1, "(document)", IssueType.INVALID, "Error parsing JSON: " + e.getMessage(), IssueSeverity.FATAL);
return null;
}
assert (map.containsKey(obj));
return parse(obj);
} else {
JsonObject obj = (JsonObject) new com.google.gson.JsonParser().parse(source);
// assert (map.containsKey(obj));
return parse(obj);
}
}
use of org.hl7.fhir.utilities.json.JsonTrackingParser.LocationData in project org.hl7.fhir.core by hapifhir.
the class JsonParser method parse.
@Override
public List<NamedElement> parse(InputStream stream) throws IOException, FHIRException {
// if we're parsing at this point, then we're going to use the custom parser
List<NamedElement> res = new ArrayList<>();
map = new IdentityHashMap<JsonElement, LocationData>();
String source = TextFile.streamToString(stream);
if (policy == ValidationPolicy.EVERYTHING) {
JsonObject obj = null;
try {
obj = JsonTrackingParser.parse(source, map, false, allowComments);
} catch (Exception e) {
logError(-1, -1, context.formatMessage(I18nConstants.DOCUMENT), IssueType.INVALID, context.formatMessage(I18nConstants.ERROR_PARSING_JSON_, e.getMessage()), IssueSeverity.FATAL);
return null;
}
assert (map.containsKey(obj));
Element e = parse(obj);
if (e != null) {
res.add(new NamedElement(null, e));
}
} else {
// (JsonObject) new com.google.gson.JsonParser().parse(source);
JsonObject obj = JsonTrackingParser.parse(source, null);
// assert (map.containsKey(obj));
Element e = parse(obj);
if (e != null) {
res.add(new NamedElement(null, e));
}
}
return res;
}
use of org.hl7.fhir.utilities.json.JsonTrackingParser.LocationData in project org.hl7.fhir.core by hapifhir.
the class JsonParser method parse.
@Override
public List<NamedElement> parse(InputStream stream) throws IOException, FHIRException {
// if we're parsing at this point, then we're going to use the custom parser
List<NamedElement> res = new ArrayList<>();
map = new IdentityHashMap<JsonElement, LocationData>();
String source = TextFile.streamToString(stream);
if (policy == ValidationPolicy.EVERYTHING) {
JsonObject obj = null;
try {
obj = JsonTrackingParser.parse(source, map, false, allowComments);
} catch (Exception e) {
logError(-1, -1, context.formatMessage(I18nConstants.DOCUMENT), IssueType.INVALID, context.formatMessage(I18nConstants.ERROR_PARSING_JSON_, e.getMessage()), IssueSeverity.FATAL);
return null;
}
assert (map.containsKey(obj));
Element e = parse(obj);
if (e != null) {
res.add(new NamedElement(null, e));
}
} else {
// (JsonObject) new com.google.gson.JsonParser().parse(source);
JsonObject obj = JsonTrackingParser.parse(source, null);
// assert (map.containsKey(obj));
Element e = parse(obj);
if (e != null) {
res.add(new NamedElement(null, e));
}
}
return res;
}
use of org.hl7.fhir.utilities.json.JsonTrackingParser.LocationData in project org.hl7.fhir.core by hapifhir.
the class JsonParser method parse.
@Override
public Element parse(InputStream stream) throws IOException, FHIRException {
// if we're parsing at this point, then we're going to use the custom parser
map = new IdentityHashMap<JsonElement, LocationData>();
String source = TextFile.streamToString(stream);
if (policy == ValidationPolicy.EVERYTHING) {
JsonObject obj = null;
try {
obj = JsonTrackingParser.parse(source, map);
} catch (Exception e) {
logError(-1, -1, "(document)", IssueType.INVALID, "Error parsing JSON: " + e.getMessage(), IssueSeverity.FATAL);
return null;
}
assert (map.containsKey(obj));
return parse(obj);
} else {
// (JsonObject) new com.google.gson.JsonParser().parse(source);
JsonObject obj = JsonTrackingParser.parse(source, null);
// assert (map.containsKey(obj));
return parse(obj);
}
}
use of org.hl7.fhir.utilities.json.JsonTrackingParser.LocationData in project org.hl7.fhir.core by hapifhir.
the class JsonParser method parse.
@Override
public Element parse(InputStream stream) throws Exception {
// if we're parsing at this point, then we're going to use the custom parser
map = new HashMap<JsonElement, LocationData>();
String source = TextFile.streamToString(stream);
if (policy == ValidationPolicy.EVERYTHING) {
JsonObject obj = null;
try {
obj = JsonTrackingParser.parse(source, map);
} catch (Exception e) {
logError(-1, -1, "(document)", IssueType.INVALID, "Error parsing JSON: " + e.getMessage(), IssueSeverity.FATAL);
return null;
}
assert (map.containsKey(obj));
return parse(obj);
} else {
JsonObject obj = (JsonObject) new com.google.gson.JsonParser().parse(source);
assert (map.containsKey(obj));
return parse(obj);
}
}
Aggregations