Posted In: Jackson 2X, JSON

How to map multiple date formats using Jackson Mapper?

Use Case – I want to map multiple date formats to ObjectMapper while converting date string to POJO Maven – Jackson 2X Solution – Use @JsonFormat @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = “yyyy-MM-dd”, timezone = “IST”)

Read More

Tags:

by , on November 27th, 2018

Posted In: Jackson 2X, JSON

How to map date format using Jackson Mapper

Use Case – I want to map particular date format to ObjectMapper while converting date string to POJO Maven – Jackson 2X Solution ObjectMapper .. mapper.setDateFormat(SimpleDateFormat);

Read More

Tags:

by , on November 26th, 2018

Posted In: Jackson 2X, JSON

Is Jackson ObjectMapper threadsafe?

Use Case – I want to make only one/few ObjectMapper objects and share them in various classes. In this case we could use immutable ObjectReader and ObjectWriter classes Comment from ObjectWriter class Maven – Jackson 2X Solution – com.fasterxml.jackson.databind.ObjectWriter ObjectWriter objectWriter = mapper.writer(); ObjectReader objectReader = mapper.reader().forType(Employee.class);

Read More

Tags: Tags: ,

by , on November 21st, 2018

Posted In: Jackson 2X, JSON

Create custom serializer using Jackson 2.X

Use Case – While creating JSON from POJO I want to add additional logic or fields to the JSON. In the following example let us add full name which is concatenation of first name and last name. In such cases we could use Jackson custom serializer class. Maven – Jackson 2X Solution – com.fasterxml.jackson.databind.ser.std.StdSerializer Following […]

Read More

Tags:

by , on November 21st, 2018

Posted In: Jackson 2X, JSON, XML

How to convert POJO to XML using Jackson library

Maven Dependency POJO Jackson 2X XmlMapper Result

Read More

Tags:

by , on September 1st, 2017

Posted In: Jackson 2X, JSON, XML

How to convert XML to POJO using Jackson library

Maven Dependency POJO Jackson 2X XmlMapper Result

Read More

Tags:

by , on September 1st, 2017

Posted In: Jackson 2X, JSON

Converting CSV to JSON using Jackson library

Maven Jackson 2X Classes used

Read More

Tags: Tags:

by , on August 31st, 2017

Posted In: Jackson 2X, JSON

How to use Jackson 2.X to read big JSON file

Usecase – You have JSON data stored at a location. It is big so do not have luxury to read it fully in ObjectMapper or you just need use some part of JSON. Jackson API provides streaming JSON parser class to do that. Maven Jackson 2X Classes used from Jackson 2X import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonParser; […]

Read More

Tags: Tags:

by , on August 8th, 2017

Posted In: Jackson 2X, JSON

Generate Json Schema from POJO – Jackson 2X

  1. Example is using Address POJO with multiple fields.   2. Use com.fasterxml.jackson.module.jsonSchema.JsonSchemaGenerator class to get schema from POJO class       3. Schema generated    

Read More

Tags: Tags: ,

by , on February 21st, 2017