Example usage for com.fasterxml.jackson.databind JsonMappingException JsonMappingException

List of usage examples for com.fasterxml.jackson.databind JsonMappingException JsonMappingException

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind JsonMappingException JsonMappingException.

Prototype

public JsonMappingException(String paramString, Throwable paramThrowable) 

Source Link

Usage

From source file:com.github.shyiko.jackson.module.advice.AdvisedBeanSerializer.java

protected void serializeFields(Object bean, JsonGenerator jgen, SerializerProvider provider)
        throws IOException {
    final BeanPropertyWriter[] props;
    if (_filteredProps != null && provider.getActiveView() != null) {
        props = _filteredProps;//from w  ww .java2  s.c o  m
    } else {
        props = _props;
    }
    int i = 0;
    try {
        for (final int len = props.length; i < len; ++i) {
            BeanPropertyWriter prop = props[i];
            if (prop != null) { // can have nulls in filtered list
                if (!beanSerializerAdvice.intercept(bean, jgen, prop, provider)) {
                    beanSerializerAdvice.before(bean, jgen, prop, provider);
                    prop.serializeAsField(bean, jgen, provider);
                    beanSerializerAdvice.after(bean, jgen, prop, provider);
                }
            }
        }
        if (_anyGetterWriter != null) {
            _anyGetterWriter.getAndSerialize(bean, jgen, provider);
        }
    } catch (Exception e) {
        String name = (i == props.length) ? "[anySetter]" : props[i].getName();
        wrapAndThrow(provider, e, bean, name);
    } catch (StackOverflowError e) {
        /* 04-Sep-2009, tatu: Dealing with this is tricky, since we do not
         *   have many stack frames to spare... just one or two; can't
         *   make many calls.
         */
        JsonMappingException mapE = new JsonMappingException("Infinite recursion (StackOverflowError)", e);
        String name = (i == props.length) ? "[anySetter]" : props[i].getName();
        mapE.prependPath(new JsonMappingException.Reference(bean, name));
        throw mapE;
    }
}

From source file:com.arpnetworking.metrics.mad.parsers.JsonToRecordParser.java

private DateTime getTimestampFor2c(final Version2c.Annotations annotations) throws JsonProcessingException {
    if (annotations.getFinalTimestamp().isPresent()) {
        try {/* ww  w  .  j  ava 2 s.c o  m*/
            return timestampToDateTime(Double.parseDouble(annotations.getFinalTimestamp().get()));
            // CHECKSTYLE.OFF: EmptyBlock - Exception triggers fallback.
        } catch (final NumberFormatException nfe) {
            // CHECKSTYLE.ON: EmptyBlock
            // Ignore.
        }
    }
    if (annotations.getInitTimestamp().isPresent()) {
        try {
            return timestampToDateTime(Double.parseDouble(annotations.getInitTimestamp().get()));
            // CHECKSTYLE.OFF: EmptyBlock - Exception triggers fallback.
        } catch (final NumberFormatException nfe) {
            // CHECKSTYLE.ON: EmptyBlock
            // Ignore.
        }
    }
    throw new JsonMappingException(null, "No timestamp found in annotations");
}