List of usage examples for com.fasterxml.jackson.core JsonParser getParsingContext
public abstract JsonStreamContext getParsingContext();
From source file:de.javagl.jgltf.model.io.JacksonUtils.java
/** * Create a DeserializationProblemHandler that may be added to an * ObjectMapper, and will handle unknown properties by forwarding * the error information to the given consumer, if it is not * <code>null</code>//w ww. j a va 2 s.com * * @param jsonErrorConsumer The consumer for {@link JsonError}s * @return The problem handler */ private static DeserializationProblemHandler createDeserializationProblemHandler( Consumer<? super JsonError> jsonErrorConsumer) { return new DeserializationProblemHandler() { @Override public boolean handleUnknownProperty(DeserializationContext ctxt, JsonParser jp, JsonDeserializer<?> deserializer, Object beanOrClass, String propertyName) throws IOException, JsonProcessingException { if (jsonErrorConsumer != null) { jsonErrorConsumer.accept( new JsonError("Unknown property: " + propertyName, jp.getParsingContext(), null)); } return super.handleUnknownProperty(ctxt, jp, deserializer, beanOrClass, propertyName); } }; }
From source file:de.javagl.jgltf.model.io.ErrorReportingSettableBeanProperty.java
@Override public void deserializeAndSet(JsonParser p, DeserializationContext ctxt, Object instance) throws IOException { try {// w ww .j av a 2 s .c o m delegate.deserializeAndSet(p, ctxt, instance); } catch (Exception e) { if (jsonErrorConsumer != null) { jsonErrorConsumer.accept(new JsonError(e.getMessage(), p.getParsingContext(), e)); } } }
From source file:org.talend.dataprep.api.dataset.LightweightExportableDataSetUtils.java
private static RowMetadata parseDataSetMetadataAndReturnRowMetadata(JsonParser jsonParser) throws IOException { try {//from w ww . j a v a 2 s . com RowMetadata rowMetadata = null; while (jsonParser.nextToken() != JsonToken.END_OBJECT && !jsonParser.isClosed()) { String currentField = jsonParser.getCurrentName(); if (StringUtils.equalsIgnoreCase("columns", currentField)) { rowMetadata = new RowMetadata(parseAnArrayOfColumnMetadata(jsonParser)); } } LOGGER.debug("Skipping data to go back to the outer json object"); while (jsonParser.getParsingContext().getParent().getCurrentName() != null && !jsonParser.isClosed()) { jsonParser.nextToken(); } return rowMetadata; } catch (IOException e) { throw new IOExceptionWithCause("Unable to parse and retrieve the row metadata", e); } }