Giter Club home page Giter Club logo

Comments (2)

ralscha avatar ralscha commented on July 30, 2024

With JavaConfig the configuration looks like this:

@bean
public JsonHandler jsonHandler() {
JsonHandler jsonHandler = new JsonHandler();

ObjectMapper objectMapper = new ObjectMapper();

SimpleModule module = new SimpleModule("GlobalSerializers", new Version(1,
0, 0, null, null, null));
module = module.addSerializer(DateTime.class, new DateTimeSerializer());
objectMapper.registerModule(module);

jsonHandler.setMapper(objectMapper);
return jsonHandler;
}

From the e4ds-mongodb-template projekt (
https://github.com/ralscha/e4ds-mongodb-template/blob/master/src/main/java/ch/rasc/e4ds/config/WebConfig.java
)

In XML something like this should work. Not sure how to configure the
ObjectMapper in XML. Maybe with a factory or something.

<bean id="mapper" class="com.fasterxml.jackson.databind.ObjectMapper"/>

<bean id="jsonHandler"
      class="ch.ralscha.extdirectspring.util.JsonHandler"
      p:mapper-ref="mapper" />

The MappingJacksonHttpMessageConverter is not used by ExtDirectSpring.
Please note that the latest ExtDirectSpring version 1.2.1 uses Jackson2.

On Fri, Oct 19, 2012 at 10:31 AM, Ilija Pavlic [email protected]:

Should we use the instructions on:

  1. http://code.google.com/p/extdirectspring/issues/detail?id=11
    setting the ObjectMapper through setter injection on
    ch.ralscha.extdirectspring.util.JsonHandler (if so, can you provide a
    configuration example?)

  2. http://code.google.com/p/extdirectspring/issues/detail?id=20
    changing the ObjectMapper through Spring configuration:

    mvc:message-converters



    /mvc:message-converters
    /mvc:annotation-driven


Reply to this email directly or view it on GitHubhttps://github.com//issues/43.

from extdirectspring.

ipavlic avatar ipavlic commented on July 30, 2024

I was looking for the XML configuration that you provided. Configuring the ObjectMapper itself won't be necessary – I'll just extend it to add what I need. So to conclude, one can just use:

<bean id="mapper" class="my.package.MyMapper"/>

and inject it to JsonHandler.

<bean id="jsonHandler" class="ch.ralscha.extdirectspring.util.JsonHandler" p:mapper-ref="mapper" />

Tested, it works. Thank you very much! The issue can be closed.

from extdirectspring.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.