Using Custom Serializers with Jackson
Jackson is a powerful library which can automatically serialize to and from JSON to Java and I have made extensive use of it in my projects. To integration with jackson you annotate the fields within your POJOs with the @JsonProperty annotation. Then using a JSON Mapper you can convert the POJOs to JSON and JSON to POJOs. For more details see my earlier article (Polymorphic JSON Serialization using Jackson). However, sometimes the default behavior of the jackson mapper falls short. In one of my projects I needed to serialize a Java class to a specific integer field within that object. This is not possible using the default ObjectMapper or its serialization config. This is where custom serializes come in using Json Serializer comes to the rescue. This article describes the use of custom serializers and deseralizers with the Jackson library.
Read full article from Using Custom Serializers with Jackson
No comments:
Post a Comment