Thank you very much, Tatu! It works now! XD Cheers! jp
On Thursday, August 25, 2016 at 2:24:46 PM UTC-4, Tatu Saloranta wrote: > > I think what you bumped into was > > MapperFeature.ALLOW_EXPLICIT_PROPERTY_RENAMING > > (defaulting to false) > > which governs whether explicitly named properties (ones with > `@JsonProperty`) are renamed or not. > Default assumption is that if you have explicit denoted name to use, that > should stick (otherwise no overrides were possible). However, if you want, > you can allow renaming even in those cases. > So you want to enable this feature. > > It may even be renamed for individual properties, although presumably in > that case explicit renaming may be simpler. > Similarly it's not clear whether you should use `@JsonProperty`, unless it > is to increase visibility. > I suspect that plain `@JsonProperty` with no String (defaulting to "") > should be renamed regardless, but haven't tested it (if it's not that seems > like a flow as that case does not specify explicit name). > > -+ Tatu +- > > > > On Thu, Aug 25, 2016 at 6:39 AM, JP <[email protected] <javascript:>> > wrote: > >> 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]> 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]. >>>> To post to this group, send email to [email protected]. >>>> 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] <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.
