[ 
https://issues.apache.org/jira/browse/JOHNZON-199?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16763687#comment-16763687
 ] 

Alexander Falb commented on JOHNZON-199:
----------------------------------------

No, my sample matches the test. But I think the asserts in the test are wrong. 
I think the first loop should assert for an empty json-string and the second 
loop for an json-string with name="..." in it.

My understanding of JohnzonIgnore is, it tells the Mapper to ignore the 
annotated field when marshaling, eg. does not put it into the json-string. The 
doc for minVersion=3 says "Or to support name for version 3, 4, … but ignore it 
for 1 and 2". So I assumed the json for version 1 and 2 would be an empty 
object and version 3, 4 have a name="..." in it?
This is contrary to the tests you linked. The minVersion in the test is set to 
2 and test asserts an empty json-string for version 2, 3 and a name="..." for 
version 0, 1, 2.

> JohnzonIgnore#minVersion logic is negated?
> ------------------------------------------
>
>                 Key: JOHNZON-199
>                 URL: https://issues.apache.org/jira/browse/JOHNZON-199
>             Project: Johnzon
>          Issue Type: Bug
>    Affects Versions: 1.1.10
>            Reporter: Alexander Falb
>            Priority: Major
>
> When a field is annotated with {{@JohnzonIgnore(minVersion = X)}} and a 
> json-string is written via {{Mapper}}, the field is only included when the 
> mapper is configured with {{.setVersion(Y)}}, where Y < X}.
> According to the documentation of {{JonzonIgnore#minVersion}} and 
> [https://johnzon.apache.org/#aJohnzonIgnore] it should be included for Y >= X.
> Is the documentation wrong or the implementation?
> Example: [https://gist.github.com/elexx/ab5dc1f3611913a0d9f409234fbecc84] 
> outputs
> {code:java}
> {}{code}
> I expected it to be
> {code:java}
> { value="valuevalue" }{code}
> To sumarize: with {{@JohnzonIgnore(minVersion = 2)}} the outputs are the 
> following:
> {code:java}
> .setVersion(1) ... {"value":"valuevalue"}
> .setVersion(2) ... {}
> .setVersion(3) ... {}
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to