Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.jackson.databind.deser.std;
 
 
 
public class ClassDeserializer
    extends StdScalarDeserializer<Class<?>>
    public ClassDeserializer() { super(Class.class); }
    @Override
    public Class<?> deserialize(JsonParser jpDeserializationContext ctxt)
        throws IOExceptionJsonProcessingException
    {
        JsonToken curr = jp.getCurrentToken();
        // Currently will only accept if given simple class name
        if (curr == .) {
            String className = jp.getText().trim();
            try {
                return ctxt.findClass(className);
            } catch (Exception e) {
                throw ctxt.instantiationException(, ClassUtil.getRootCause(e));
            }
        }
        throw ctxt.mappingException(curr);
    }
New to GrepCode? Check out our FAQ X