PDA

View Full Version : How to use JacksonJsonRedisSerializer??



rvkhakhkhar
Aug 24th, 2011, 04:36 AM
I want to push JSONObject in the list <String,JSONObject>
I'm using spring data redis 1.0.0.M4

How can I use JacksonJsonRedisSerializer to do that or can provide your way.

Costin Leau
Aug 25th, 2011, 02:38 AM
You'll have to expand on that since I don't understand what your problem is.
Note there's a sample that you can use to get you started.

slyfox
Aug 29th, 2011, 11:11 AM
Here is my config:
<bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTem plate"
p:connection-factory-ref="redisConnectionFactory">
<property name="ValueSerializer" ref="redisJsonSerializer"/>
</bean>
<bean id="redisJsonSerializer" class="org.springframework.data.redis.serializer.JacksonJ sonRedisSerializer">
<constructor-arg type="java.lang.Class" value="your.class.here"/>
</bean>

note that I only used the JacksonJsonRedisSerializer for the value and not the key, for me the key is still a plain ol string.

Costin Leau
Aug 31st, 2011, 03:22 AM
Sounds like a Jackson specific problem. There are plenty of results on google such as this one: http://www.cowtowncoder.com/blog/archives/2011/03/entry_447.html