Package org.codehaus.jackson.map.introspect

Examples of org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector


      protected ObjectMapper initialValue() {

        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        AnnotationIntrospector introspector = new AnnotationIntrospector.Pair(new JaxbAnnotationIntrospector(),
            new JacksonAnnotationIntrospector());

        SerializationConfig sc = mapper.getSerializationConfig().withSerializationInclusion(
            JsonSerialize.Inclusion.NON_NULL);
        mapper.setSerializationConfig(sc.withAnnotationIntrospector(introspector));
        mapper.setDeserializationConfig(mapper.getDeserializationConfig().withAnnotationIntrospector(
View Full Code Here



    private static JsonFactory createJsonFactory() {
        JsonFactory jsonFactory = new JsonFactory();
        ObjectMapper mapper = new ObjectMapper(jsonFactory);
        mapper.getSerializationConfig().setAnnotationIntrospector(new JacksonAnnotationIntrospector());
        mapper.getSerializationConfig().setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
        mapper.getDeserializationConfig().disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);
        jsonFactory.setCodec(mapper);
        return jsonFactory;
    }
View Full Code Here

public class JsonSerializer<T> {

    public String toJSON(T object) throws IOException {
        JsonFactory jsonFactory = new JsonFactory();
        ObjectMapper mapper = new ObjectMapper(jsonFactory);
        mapper.getSerializationConfig().setAnnotationIntrospector(new JacksonAnnotationIntrospector());
        mapper.getSerializationConfig().setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
        jsonFactory.setCodec(mapper);
        StringWriter writer = new StringWriter();
        JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(writer);
        jsonGenerator.useDefaultPrettyPrinter();
View Full Code Here

    }

    public JsonFactory createJsonFactory() {
        JsonFactory jsonFactory = new JsonFactory();
        ObjectMapper mapper = new ObjectMapper(jsonFactory);
        mapper.getSerializationConfig().setAnnotationIntrospector(new JacksonAnnotationIntrospector());
        mapper.getSerializationConfig().setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
        jsonFactory.setCodec(mapper);
        return jsonFactory;
    }
View Full Code Here

    }

    private static Pair createJaxbJacksonAnnotationIntrospector() {

        final AnnotationIntrospector jaxbIntrospector = new JaxbAnnotationIntrospector();
        final AnnotationIntrospector jacksonIntrospector = new JacksonAnnotationIntrospector();

        return new AnnotationIntrospector.Pair(jacksonIntrospector, jaxbIntrospector);
    }
View Full Code Here

                                    + " for " + key);
                }
            }
        }
        if (primary == null) {
            primary = new JacksonAnnotationIntrospector(); // support default
            getLogger().info(
                    "using default introspector:"
                            + primary.getClass().getName());
            mapper.setAnnotationIntrospector(primary);
        } else {
View Full Code Here

*/
public class JacksonHelper {
    public static ObjectMapper createObjectMapper() {
        ObjectMapper mapper = new ObjectMapper();
        AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
        AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
        AnnotationIntrospector pair = new AnnotationIntrospector.Pair(primary, secondary);
        mapper.getDeserializationConfig().setAnnotationIntrospector(pair);
        // [rfeng] To avoid complaints about javaClass
        mapper.getDeserializationConfig().set(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.FALSE);
        mapper.getSerializationConfig().setAnnotationIntrospector(pair);
View Full Code Here

     */

    public void testSimple()
    {
        // null -> no mix-in annotations
        AnnotatedClass ac = AnnotatedClass.construct(SubClass.class, new JacksonAnnotationIntrospector(), null);
        ac.resolveMemberMethods(BasicClassIntrospector.GetterMethodFilter.instance);
        ac.resolveCreators(true);
        ac.resolveFields();

        assertNotNull(ac.getDefaultConstructor());
View Full Code Here

     * from a sub-class is used instead of abstract one from superclass.
     */
    public void testGenericsWithSetter()
    {
        // null -> no mix-in annotations
        AnnotatedClass ac = AnnotatedClass.construct(NumberBean.class, new JacksonAnnotationIntrospector(), null);
        ac.resolveMemberMethods(BasicClassIntrospector.SetterMethodFilter.instance);
        assertEquals(1, ac.getMemberMethodCount());

        Iterator<AnnotatedMethod> it = ac.memberMethods().iterator();
        AnnotatedMethod am = it.next();
View Full Code Here

    }

    public void testFieldIntrospection()
    {
        // null -> no mix-in annotations
        AnnotatedClass ac = AnnotatedClass.construct(FieldBean.class, new JacksonAnnotationIntrospector(), null);
        ac.resolveFields();
        /* 14-Jul-2009, tatu: AnnotatedClass does remove forcibly ignored
         *   entries, but will still contain non-public fields too (earlier
         *   versions didn't, but filtering was moved to a later point)
         */
 
View Full Code Here

TOP

Related Classes of org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.