use of com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector in project oxCore by GluuFederation.
the class Util method createJsonMapper.
/**
* Creates json mapper.
*
* @return json mapper
*/
public static ObjectMapper createJsonMapper() {
final AnnotationIntrospector jaxb = new JaxbAnnotationIntrospector();
final AnnotationIntrospector jackson = new JacksonAnnotationIntrospector();
final AnnotationIntrospector pair = AnnotationIntrospector.pair(jackson, jaxb);
final ObjectMapper mapper = new ObjectMapper();
mapper.setAnnotationIntrospector(pair);
return mapper;
}
use of com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector in project jackson-databind by FasterXML.
the class TestVersions method testMapperVersions.
public void testMapperVersions() {
ObjectMapper mapper = new ObjectMapper();
assertVersion(mapper);
assertVersion(mapper.reader());
assertVersion(mapper.writer());
assertVersion(new JacksonAnnotationIntrospector());
}
use of com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector in project OpenTripPlanner by opentripplanner.
the class SerializerUtils method getMapper.
public static ObjectMapper getMapper() {
ObjectMapper mapper = new ObjectMapper();
AnnotationIntrospector aipair = new AnnotationIntrospectorPair(new JaxbAnnotationIntrospector(), new JacksonAnnotationIntrospector());
mapper.setAnnotationIntrospector(aipair);
// REMOVE: mapper.configure(SerializationConfig.Feature.USE_ANNOTATIONS, true);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
return mapper;
}
use of com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector in project endpoints-java by cloudendpoints.
the class ObjectMapperUtil method createStandardObjectMapper.
/**
* Creates an Endpoints standard object mapper that allows unquoted field names and unknown
* properties.
*
* Note on unknown properties: When Apiary FE supports a strict mode where properties
* are checked against the schema, BE can just ignore unknown properties. This way, FE does
* not need to filter out everything that the BE doesn't understand. Before that's done,
* a property name with a typo in it, for example, will just be ignored by the BE.
*/
public static ObjectMapper createStandardObjectMapper(ApiSerializationConfig config) {
ObjectMapper objectMapper = new ObjectMapper().configure(JsonParser.Feature.ALLOW_COMMENTS, true).configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true).configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true).configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).setBase64Variant(Base64Variants.MODIFIED_FOR_URL).setSerializerFactory(BeanSerializerFactory.instance.withSerializerModifier(new DeepEmptyCheckingModifier()));
AnnotationIntrospector pair = AnnotationIntrospector.pair(new ApiAnnotationIntrospector(config), new JacksonAnnotationIntrospector());
objectMapper.setAnnotationIntrospector(pair);
return objectMapper;
}
use of com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector in project build-info by JFrogDev.
the class JsonSerializer method toJSON.
public String toJSON(T object) throws IOException {
JsonFactory jsonFactory = new JsonFactory();
ObjectMapper mapper = new ObjectMapper(jsonFactory);
mapper.setAnnotationIntrospector(new JacksonAnnotationIntrospector());
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
jsonFactory.setCodec(mapper);
StringWriter writer = new StringWriter();
JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(writer);
jsonGenerator.useDefaultPrettyPrinter();
jsonGenerator.writeObject(object);
return writer.getBuffer().toString();
}
Aggregations