0

I'm attempting to upgrade from Jackson 1.x to 2.x.

One area I'm having problems is where I was using a custom DeserializerFactory it looked like this:

objectMapper.setDeserializerProvider(objectMapper.getDeserializerProvider()
                                                   .withFactory(myFactory));

setDeserializerProvider is now gone in Jackson2 (although setSerializerProvider is still there). I was looking at using SimpleModule but that doesn't have what I need either.

How is this supposed to work in 2?

Update: I feel the need to emphasize that it needs to be a FACTORY. Not just registering a deserializer.

The custom factory passes information on to the Deserializer like this:

if (CollectionPage.class.equals(type.getRawClass())) {
        final JsonDeserializer<Object> contentDeserializer = type.getContentType().getValueHandler();
        return new MyCollectionDeserializer(type, contentDeserializer);
    }

That value (contentDeserializer) is different at runtime for collections containing different types.

ryber
  • 4,537
  • 2
  • 26
  • 50
  • What exactly doesn't work when you are using `SimpleModule` ? – sol4me Jan 02 '15 at 14:22
  • SimpleModule lets you register JsonDeserializers, not factories. In my case it needs to be the Factory because the factory returns custom JsonDeserializers based on the CollectionType at runtime – ryber Jan 02 '15 at 15:16
  • It may be somewhat of a crossover of the other question but what I'm looking for was never answered. How to inject the factory. – ryber Jan 02 '15 at 15:17
  • I found the answer and posted it in the other question since it didn't actually have a proper answer to the question. – ryber Jan 04 '15 at 13:38

0 Answers0