Merge pull request #7174 from amit2103/BAEL-14274-8

[BAEL-14274] - Fixed article code for https://www.baeldung.com/jackso
This commit is contained in:
Loredana Crusoveanu 2019-11-02 17:40:44 +02:00 committed by GitHub
commit 817e6e69fd
1 changed files with 12 additions and 0 deletions

View File

@ -1,8 +1,10 @@
package com.baeldung.jackson.annotation; package com.baeldung.jackson.annotation;
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonSetter;
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonPropertyOrder({ "name", "id" }) @JsonPropertyOrder({ "name", "id" })
@ -18,4 +20,14 @@ public class MyBean {
this.id = id; this.id = id;
this.name = name; this.name = name;
} }
@JsonGetter("name")
public String getTheName() {
return name;
}
@JsonSetter("name")
public void setTheName(String name) {
this.name = name;
}
} }