Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to serialize/deserialize third party Java objects with Jackson

As an example, I'd like to serialize/deserialize one object of Slick2d's Animation class using Jackson. What is the simplest way to do this?

like image 578
Mitch Avatar asked Aug 21 '11 08:08

Mitch


2 Answers

You can annotate a mix-in interface if you want to control the generated json on third party classes.

read more here: http://wiki.fasterxml.com/JacksonMixInAnnotations

Update: The current documentation (v2+) is here: https://github.com/FasterXML/jackson-docs/wiki/JacksonMixInAnnotations

like image 156
henrik_lundgren Avatar answered Oct 09 '22 09:10

henrik_lundgren


Just as any object - pass it to objectMapper.readValue(..) / objectMapper.writeValue(..)

like image 21
Bozho Avatar answered Oct 09 '22 10:10

Bozho