Example usage for com.fasterxml.jackson.databind.introspect JacksonAnnotationIntrospector JacksonAnnotationIntrospector

List of usage examples for com.fasterxml.jackson.databind.introspect JacksonAnnotationIntrospector JacksonAnnotationIntrospector

Introduction

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

Prototype

JacksonAnnotationIntrospector

Source Link

Usage

From source file:fr.norad.jaxrs.doc.plugin.DocGeneratorMojo.java

public DocGeneratorMojo() {
    objectMapper = new ObjectMapper();
    objectMapper.setSerializationInclusion(Include.NON_NULL);
    objectMapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(new JacksonAnnotationIntrospector(),
            new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())));
}

From source file:eu.modaclouds.sla.mediator.generation.TemplateGenerator.java

private <T> String toJson(T t) throws JsonProcessingException {
    if (jsonMapper == null) {
        jsonMapper = new ObjectMapper();
        AnnotationIntrospector introspector = new JacksonAnnotationIntrospector();
        jsonMapper.getSerializationConfig().with(introspector);
        jsonMapper.setSerializationInclusion(Include.NON_NULL);
    }//from ww w.  ja  v  a2 s .  com

    return jsonMapper.writeValueAsString(t);
}

From source file:com.unilever.audit.services2.Sync_Down.java

/**
 * Retrieves representation of an instance of
 * com.unilever.audit.services2.AuditResource
 *
 * @param id// w ww .  j  av  a  2  s.co  m
 * @param dataType
 * @return an instance of java.lang.String
 */
@GET
@Path("getSyncObject/{id}/{dataType}/{compress}")
@Produces("application/json")
public byte[] getSyncObject(@PathParam("id") int id, @PathParam("dataType") String dataType,
        @PathParam("compress") int compress) {

    GZIPOutputStream gzip = null;
    count++;
    ByteArrayOutputStream out = null;
    SyncDownObjects syncDownObjects = getObject(dataType, id);

    try {
        out = new ByteArrayOutputStream();
        gzip = new GZIPOutputStream(out);

        ObjectMapper mapper = new ObjectMapper();
        AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
        AnnotationIntrospector introspector1 = new JacksonAnnotationIntrospector();
        mapper.setAnnotationIntrospectors(introspector, introspector1);
        mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));

        //String jsonString = mapper.writeValueAsString(syncDownObjects);
        //JSONObject jsonobject = (JSONObject) new JSONParser().parse(jsonString);
        //gzip.write(jsonobject.toString().getBytes("8859_1"));
        //gzip.write(jsonobject.toString().getBytes("UTF-8"));
        gzip.write(mapper.writeValueAsBytes(syncDownObjects));
        gzip.close();

    } catch (IOException ex) {
        ex.printStackTrace();
    } //catch (ParseException ex) {
      // ex.printStackTrace();
      // }
    System.out.println("======================= count : " + count);
    return out.toByteArray();
}

From source file:org.openecomp.sdnc.sli.aai.AAIService.java

public static ObjectMapper getObjectMapper() {
    ObjectMapper mapper = new ObjectMapper();
    AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
    AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
    mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(introspector, secondary));
    mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    mapper.setSerializationInclusion(Include.NON_NULL);
    return mapper;
}