Hi Tatu, Thanks for the tip about PropertyNamingStrategy!
However, I couldn't get it to work... I created my own class extending the PropertyNamingStrategy class, and overrode the nameForField(), nameForGetterMethod(), nameForSetterMethod() functions. I created an instance of this class and added it to my ObjectMapper using the setPropertyNamingStrategy() method. But during execution, my overridden methods were not called. My POJO has all the fields and also the setters/getters annotated wtih @JsonProperty as well. There are no errors. My POJO still gets populated with the JSON values. However, my PropertyNamingStrategy class does not seem to get used during execution. Is there some other ObjectMapper configuration I need to set to trigger the use of the PropertyNamingStrategy? Thanks, jp On Wednesday, August 24, 2016 at 2:18:11 PM UTC-4, Tatu Saloranta wrote: > > As a general answer, I am always open to new ideas. :) > > In this specific case I am not quite sure how this could be implemented, > considering the way Jackson handles properties and introspection. > > However... come to think of this, there is one piece of configurability > that might help here. `PropertyNamingStrategy` may be used to change name > mapping from POJO property (derived from getter/setter, field, or > annotation) to/from external name used in JSON. It is therefore possible to > have different strategy, and one that does not have to merely change casing > or punctuation but may completely change the name. > > One downside with this is that you can not dynamically change the > strategy; it is static setup (set once per ObjectMapper), so you'd need > separate mapper for each distinct deployment. That may or may not work for > you. > > -+ Tatu +- > > > On Wed, Aug 24, 2016 at 10:28 AM, JP <[email protected] <javascript:>> > wrote: > >> Thanks, Tatu. >> >> I think this would be a useful feature to have perhaps in a future >> release? ;) >> >> Especially considering there are more and more user-configurable systems >> offering REST APIs (eg. JIRA) where fields names will be changing. >> >> Best regards, >> jp >> >> -- >> You received this message because you are subscribed to the Google Groups >> "jackson-user" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "jackson-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
