Example usage for com.fasterxml.jackson.datatype.joda JodaModule JodaModule

List of usage examples for com.fasterxml.jackson.datatype.joda JodaModule JodaModule

Introduction

In this page you can find the example usage for com.fasterxml.jackson.datatype.joda JodaModule JodaModule.

Prototype

public JodaModule() 

Source Link

Usage

From source file:com.microsoft.rest.serializer.JacksonMapperAdapter.java

/**
 * Initializes an instance of JacksonMapperAdapter with default configurations
 * applied to the object mapper.//from  w w w.  j a  va2 s  .  c  o  m
 *
 * @param mapper the object mapper to use.
 */
protected void initializeObjectMapper(ObjectMapper mapper) {
    mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
            .configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true)
            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
            .configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true)
            .setSerializationInclusion(JsonInclude.Include.NON_NULL).registerModule(new JodaModule())
            .registerModule(ByteArraySerializer.getModule()).registerModule(DateTimeSerializer.getModule())
            .registerModule(DateTimeRfc1123Serializer.getModule())
            .registerModule(HeadersSerializer.getModule());
    mapper.setVisibility(mapper.getSerializationConfig().getDefaultVisibilityChecker()
            .withFieldVisibility(JsonAutoDetect.Visibility.ANY)
            .withSetterVisibility(JsonAutoDetect.Visibility.NONE)
            .withGetterVisibility(JsonAutoDetect.Visibility.NONE)
            .withIsGetterVisibility(JsonAutoDetect.Visibility.NONE));
}

From source file:com.nesscomputing.jackson.NessJacksonModule.java

@Override
public void configure() {
    // Annotated version (@Json) is also bound to json.
    bind(ObjectMapper.class).annotatedWith(JsonMapper.class).toProvider(NessObjectMapperProvider.class)
            .in(Scopes.SINGLETON);//from   ww w.j  a  v  a  2s  .  c om

    // Annotated version (@Smile) is bound to the smile factory.
    bind(ObjectMapper.class).annotatedWith(SmileMapper.class)
            .toProvider(new NessObjectMapperProvider(new SmileFactory())).in(Scopes.SINGLETON);

    // Default (not annotated) instance is bound to json.
    bind(ObjectMapper.class).toProvider(NessObjectMapperProvider.class).in(Scopes.SINGLETON);

    bind(NessJacksonConfig.class).toProvider(ConfigProvider.of(NessJacksonConfig.class)).in(Scopes.SINGLETON);

    NessObjectMapperBinder.bindJacksonModule(binder()).toInstance(new GuavaModule());
    NessObjectMapperBinder.bindJacksonModule(binder()).toInstance(new JodaModule());

    install(new NessCustomSerializerModule());

    // MrBean is pretty safe to globally install, since it only deserializes types that would otherwise fail.
    NessObjectMapperBinder.bindJacksonModule(binder()).to(MrBeanModule.class);

    NessObjectMapperBinder.bindJacksonModule(binder()).to(AfterburnerModule.class);
}

From source file:com.nissatech.proasense.eventplayer.partnerconfigurations.HellaConfiguration.java

/**
 * {@inheritDoc}/*from w w  w  .ja v a 2s .co m*/
 */
@Override
public String generateMessage(Row row) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JodaModule());
    mapper.setDateFormat(new ISO8601DateFormat());
    HashMap message = new HashMap();
    DateTime date = new DateTime(row.getDate("variable_timestamp"));
    message.put("variable_timestamp", date);
    message.put("values", row.getMap("values", String.class, String.class));
    message.put("variable_type", row.getString("variable_type"));
    return mapper.writeValueAsString(message);

}

From source file:com.proofpoint.json.ObjectMapperProvider.java

public ObjectMapperProvider() {
    modules.add(new Jdk8Module());
    modules.add(new JSR310Module());
    modules.add(new GuavaModule());
    modules.add(new JodaModule());
}

From source file:net.greghaines.ghorgbrowser.GitHubOrgBrowserApplication.java

/**
 * {@inheritDoc}/* ww  w  .  j  a  v  a  2 s . co m*/
 */
@Override
public void initialize(final Bootstrap<GitHubOrgBrowserConfiguration> bootstrap) {
    bootstrap.addBundle(new AssetsBundle());
    bootstrap.addBundle(new WebJarBundle());
    bootstrap.addBundle(new ViewBundle());
    bootstrap.getObjectMapper().registerModule(new JodaModule());
}

From source file:com.hp.autonomy.searchcomponents.hod.search.fields.HodSearchResultDeserializerTest.java

@Before
public void setUp() {
    objectMapper = new ObjectMapper();
    final SimpleModule customModule = new SimpleModule();
    customModule.addDeserializer(HodSearchResult.class, new HodSearchResultDeserializer(configService));
    objectMapper.registerModule(customModule);
    objectMapper.registerModule(new JodaModule());

    final FieldsInfo fieldsInfo = new FieldsInfo.Builder()
            .populateResponseMap("modifiedDate",
                    new FieldInfo<DateTime>("modifiedDate", Arrays.asList("modified_date", "date_modified"),
                            FieldType.DATE))
            .populateResponseMap("links",
                    new FieldInfo<String>("links", Collections.singletonList("links"), FieldType.STRING))
            .build();//from  w w w .  j a  v  a 2s  .  c o  m
    when(config.getFieldsInfo()).thenReturn(fieldsInfo);
    when(configService.getConfig()).thenReturn(config);
}

From source file:fi.hsl.parkandride.itest.AbstractIntegrationTest.java

@Before
public void setup() {
    RestAssured.port = port;/* www. j  av a2 s  .  c  om*/

    objectMapper.registerModule(new JodaModule());
    objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    RestAssured.config = config().objectMapperConfig(
            objectMapperConfig().jackson2ObjectMapperFactory((cls, charset) -> objectMapper));
}

From source file:org.efaps.cli.rest.CINameProviderCall.java

/**
 * Gets the CI name provider./*from   w w  w  .ja v  a  2  s  .co  m*/
 *
 * @return the CI name provider
 */
public ICINameProvider execute() {
    ICINameProvider ret = null;
    try {
        init();
        final String eql = "print query type Admin_DataModel_Type select attribute[Name]";
        final Response response = getWebTarget().queryParam("origin", "eFaps-CLI").queryParam("stmt", eql)
                .request(MediaType.TEXT_PLAIN_TYPE, MediaType.APPLICATION_JSON_TYPE).get();
        final BufferedReader br = new BufferedReader(
                new InputStreamReader(response.readEntity(InputStream.class)));
        final ObjectMapper mapper = new ObjectMapper();
        mapper.registerModule(new JodaModule());
        final Object obj = mapper.readValue(br, AbstractEFapsJSON.class);
        if (obj instanceof ErrorReply) {
            getErrorReply(response, (ErrorReply) obj);
        } else {
            final DataList dataList = (DataList) obj;
            final Set<String> typeNames = new HashSet<>();
            for (final ObjectData data : dataList) {
                typeNames.add((String) data.getValues().get(0).getValue());
            }
            ret = new ICINameProvider() {
                @Override
                public Set<String> getTypeNames() {
                    return typeNames;
                }
            };
        }
    } catch (final IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return ret;
}

From source file:io.airlift.json.ObjectMapperProvider.java

public ObjectMapperProvider() {
    modules.add(new Jdk7Module());
    modules.add(new Jdk8Module());
    modules.add(new JSR310Module());
    modules.add(new GuavaModule());
    modules.add(new JodaModule());
}

From source file:org.efaps.rest.AbstractRest.java

/**
 * Gets the JSON reply.//  ww w  .j a  va2  s .  co m
 *
 * @param _jsonObject the _json object
 * @return the JSON reply
 * @throws JsonProcessingException the json processing exception
 */
protected String getJSONReply(final Object _jsonObject) {
    String ret = "";
    final ObjectMapper mapper = new ObjectMapper();
    if (LOG.isDebugEnabled()) {
        mapper.enable(SerializationFeature.INDENT_OUTPUT);
    }
    mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    mapper.registerModule(new JodaModule());
    try {
        ret = mapper.writeValueAsString(_jsonObject);
    } catch (final JsonProcessingException e) {
        LOG.error("Catched JsonProcessingException", e);
    }
    return ret;
}