Ravi M
Ravi M

Reputation: 231

Upgrade of Jackson from org.codehaus.jackson to com.fasterxml.jackson (version 1.9.13 --> 2.9.8)

In our code we have org.codehaus.jackson imports in java file. now we are moving to com.fasterxml.jackson.

What are the points are to be considered for smooth up gradation?

Upvotes: 6

Views: 13388

Answers (3)

Ravi M
Ravi M

Reputation: 231

Following are some of the changes identified between Jackson 1.9.x and Jackson 2.9.8

  1. org.codehaus.jackson changed to com.fasterxml.jackson
  2. org.codehaus.jackson.map changed to com.fasterxml.jackson.databind
  3. SerializationConfig.Feature changed and split to SerializationFeature,MapperFeature
  4. DeSerializationConfig.Feature changed and split to DeSerializationFeature,MapperFeature
  5. AnnotationIntrospector.Pair changed to AnnotationIntrospectorPair
  6. SerializationConfig.withAnnotationIntrospectro(...) changed to SerializationConfig.with(...)
  7. ObjectMapper.getSerilizationConfig().addMixInAnnotations(...) changed to ObjectMapper.addMixIn(....)
  8. JSonSerialize.include changed to JSonInclude
  9. ObjectMapper.readValue(JSonNode,...) changed to ObjectMapper.readValue(ObjectMapper.treeAsTokens(JSonNode),...)

Upvotes: 12

Sarfraz Shaikh
Sarfraz Shaikh

Reputation: 552

I would like to add one more point to @Ravi's Answer.

In jackson-databind-2.9.8, java.sql.Date by default will be serialized to numeric timestamp instead of StdDateFormat. This will specifically cause an issue when expected date format is StdDateFormat.

Refer release notes

java.sql.Date As per databind#219 java.sql.Date will finally use same "timestamp-or-String" determination as java.util.Date and java.util.Calendar. This means that with vanilla, unchanged settings, values will be serialized as numeric timestamps. Note that the default String serialization will still default to java.sql.Date.String(), and not to default formatting java.util.Date uses.

Upvotes: 1

gprasadr8
gprasadr8

Reputation: 879

Upgrading from jackson-1.X to jackson 2.X

  1. Update the dependencies from jackson-core-asl-1.X.jar and jackson-mapper-asl-1.X.jar to jackson-annotations.jar, jackson-core.jar, and jackson-databind.jar
  2. Fix imports from org.codehaus.jackson to com.fasterxml.jackson
  3. change the get method names to direct names

    For Example:

    jackson-1.X methods: getBooleanValue(), getFields(), getElements(), getIntValue()

    jackson-2.X methods: booleanValue(), fields(), elements(), and intValue()

Upvotes: 8

Related Questions