use of com.fasterxml.jackson.datatype.joda.JodaModule in project mica2 by obiba.
the class TestUtil method convertObjectToJsonBytes.
/**
* Convert an object to JSON byte array.
*
* @param object the object to convert
* @return the JSON byte array
* @throws IOException
*/
public static byte[] convertObjectToJsonBytes(Object object) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JodaModule());
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
return mapper.writeValueAsBytes(object);
}
use of com.fasterxml.jackson.datatype.joda.JodaModule in project oap by oaplatform.
the class ParserPerformance method performance.
@Test
public void performance() {
final ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new Jdk8Module());
final JodaModule module = new JodaModule();
module.addDeserializer(DateTime.class, forType(DateTime.class));
module.addSerializer(DateTime.class, new DateTimeSerializer(jodaDateFormat, 0));
mapper.registerModule(module);
mapper.enable(DeserializationFeature.USE_LONG_FOR_INTS);
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.registerModule(new OapJsonModule());
benchmark("mapParser-jackson", 5000, () -> mapper.writeValueAsString(mapper.readValue(yearJson, Map.class))).run();
final ObjectMapper mapper2 = new ObjectMapper();
mapper2.registerModule(new Jdk8Module());
mapper2.registerModule(module);
mapper2.enable(DeserializationFeature.USE_LONG_FOR_INTS);
mapper2.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper2.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper2.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
mapper2.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper2.registerModule(new OapJsonModule());
mapper2.registerModule(new AfterburnerModule());
benchmark("mapParser-jackson2", 5000, () -> mapper2.writeValueAsString(mapper2.readValue(yearJson, Map.class))).run();
}
use of com.fasterxml.jackson.datatype.joda.JodaModule in project cloudconductor-agent-redhat by cinovo.
the class MapperFactory method createDefault.
public static ObjectMapper createDefault() {
ObjectMapper m = new ObjectMapper();
m.registerModule(new JodaModule());
m.registerModule(new GuavaModule());
m.setSerializationInclusion(Include.NON_NULL);
m.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
m.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
m.enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
m.enable(MapperFeature.AUTO_DETECT_GETTERS);
return m;
}
use of com.fasterxml.jackson.datatype.joda.JodaModule in project kylo by Teradata.
the class ObjectMapperSerializer method getMapper.
/**
* Return a reference to the Jackson2 ObjectMapper
*
* @return the ObjectMapper used to serialize/deserialize
*/
private static ObjectMapper getMapper() {
if (mapper == null) {
mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.registerModule(new JodaModule());
}
return mapper;
}
use of com.fasterxml.jackson.datatype.joda.JodaModule in project pictureapp by EyeSeeTea.
the class SurveyChecker method getEvents.
public static List<EventExtended> getEvents(JsonNode jsonNode) {
TypeReference<List<Event>> typeRef = new TypeReference<List<Event>>() {
};
List<Event> events;
try {
if (jsonNode.has("events")) {
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JodaModule());
events = objectMapper.readValue(jsonNode.get("events").traverse(), typeRef);
} else {
events = new ArrayList<>();
}
} catch (IOException e) {
events = new ArrayList<>();
e.printStackTrace();
}
List<EventExtended> eventExtendedList = new ArrayList<>();
for (Event event : events) {
EventFlow eventFlow = EventFlow.MAPPER.mapToDatabaseEntity(event);
EventExtended eventExtended = new EventExtended(eventFlow);
if (event.getDataValues() != null && event.getDataValues().size() > 0) {
List<TrackedEntityDataValueFlow> trackedEntityDataValueFlows = TrackedEntityDataValueFlow.MAPPER.mapToDatabaseEntities(event.getDataValues());
eventExtended.setDataValuesInMemory(trackedEntityDataValueFlows);
}
eventExtendedList.add(eventExtended);
}
return eventExtendedList;
}
Aggregations