0

I have a JSON string which I want to serialize in a Java object, one of the properties in the json string doesn't match the name of field in the Java object, I know this can be fixed using the @JSONProperty as mentioned here - Jackson annotation - How to rename element names?

But I don't have access to the source code of the Java object thus I can't add the annotation, is there a way to do this at runtime by providing some configuration code to the ObjectMapper? I am using Jackson version 1.9.

Thanks,

Community
  • 1
  • 1
Tarun Sapra
  • 1,851
  • 6
  • 26
  • 40
  • 1
    Jackson 1.9? That's prehistoric! Why not 2.6.x? – fge Nov 25 '15 at 17:20
  • I know it's old but so is the application i am maintaining. – Tarun Sapra Nov 25 '15 at 17:21
  • found the answer here - http://www.studytrails.com/java/json/java-jackson-mix-in-annotation.jsp, it's a better example than the link shared as the duplicate question – Tarun Sapra Nov 25 '15 at 17:28
  • We can only link Stack Overflow posts as duplicates. The [accepted answer](http://stackoverflow.com/a/29391616/438154) gives a complete example. – Sotirios Delimanolis Nov 25 '15 at 17:38
  • Hi @SotiriosDelimanolis - the accepted answer has the mixin declared and defined but how to register them with the objectMapper isn't provided that's why I had shared another link which provides the way to register the mixin with the object mapper as well. – Tarun Sapra Nov 26 '15 at 08:22
  • It has both. Just scroll all the way to the bottom. – Sotirios Delimanolis Nov 26 '15 at 13:36

0 Answers0