use of com.linkedin.avroutil1.parser.exceptions.JsonParseException in project avro-util by linkedin.
the class AvscParser method parse.
public AvscParseResult parse(String avsc) {
JsonReaderExt jsonReader = new JsonReaderWithLocations(new StringReader(avsc), null);
JsonObjectExt root;
AvscFileParseContext context = new AvscFileParseContext(avsc);
AvscParseResult result = new AvscParseResult();
try {
root = jsonReader.readObject();
} catch (JsonParsingException e) {
Throwable rootCause = Util.rootCause(e);
String message = rootCause.getMessage();
if (message != null && message.startsWith("Unexpected char 47")) {
// 47 is ascii for '/' (utf-8 matches ascii on "low" characters). we are going to assume this means
// someone tried putting a //comment into an avsc source
result.recordError(new JsonParseException("comments not supported in json at" + e.getLocation(), e));
} else {
result.recordError(new JsonParseException("json parse error at " + e.getLocation(), e));
}
return result;
} catch (Exception e) {
result.recordError(new JsonParseException("unknown json parse error", e));
return result;
}
try {
parseSchemaDeclOrRef(root, context, true);
context.resolveReferences();
result.recordParseComplete(context);
} catch (Exception parseIssue) {
result.recordError(parseIssue);
}
return result;
}
Aggregations