johnzon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Falb (JIRA)" <>
Subject [jira] [Commented] (JOHNZON-200) ConstructorProperties with custom-named fields (JohnzonProperty)
Date Mon, 11 Feb 2019 09:10:00 GMT


Alexander Falb commented on JOHNZON-200:

Unfortunatly I'm stuck on EE7 for now, so no JSON-B for me :(

Ok I see - I'll close this issue.

> ConstructorProperties with custom-named fields (JohnzonProperty)
> ----------------------------------------------------------------
>                 Key: JOHNZON-200
>                 URL:
>             Project: Johnzon
>          Issue Type: Bug
>          Components: Mapper
>    Affects Versions: 1.1.11
>            Reporter: Alexander Falb
>            Priority: Minor
> I'm not sure if this is a bug or just unexpected behaviour:
> When I map a JSON field named "$version" to a Java field named "version" and this field
is mandatory/final I have to annotate the constuctor like this:
> {code:java}
> public static class MyBean {
>     @JohnzonProperty("$version") private final int version;
>     @ConstructorProperties("$version") public MyBean(int version) {
>         this.version = version;
>     }
> ...{code}
> I would expect the value of {{ConstructorProperties}} to be {{version}} (without the
dollar $ sign), because the documentation of {{ConstructorProperties}} says:
> {quote}An annotation on a constructor that shows how the parameters of
>  that constructor correspond to the constructed object's getter
>  methods. [...]
> {quote}
> but is actually has to be the JSON field name.
> In my optinion this is quite unexpected and also from a maintainability point of view
I think declaring the custom naming twice is bad. - I think the {{ConstructorProperties}}
should the the Java field names and not the JSON name (or for backward compatability maybe

This message was sent by Atlassian JIRA

View raw message