@JSONProperty for a field 'is_deleted' is serialized as `_deleted`
See original GitHub issueHi, I am using Jackson 2.9.5. I have an Entity Structure Like this.
@Entity
@Data
public class PersonEntity {
@JsonProperty("is_deleted")
private boolean is_deleted;
}
On Deserialization, there are 2 fields.
{
"_deleted" : "true",
"is_deleted":"true"
}
Setting any 1 of the above from REST Client sets the value for the field is_deleted
.
Suppose, I tweak my value a little bit and change my Entity as
@Entity
@Data
public class PersonEntity {
@JsonProperty("is_deleted")
private boolean isDeleted;
}
Again I get 2 fields on serialization,
{
"deleted" : "true",
"is_deleted":"true"
}
Setting any any 1 of the above from REST Client sets the value for the field isDeleted
.
However, when I change this field without the is part,
@Entity
@Data
public class PersonEntity {
@JsonProperty("is_deleted")
private boolean deleted;
}
there is only 1 field that is correctly serialized as is_deleted
.
I use Lombok for getters and setters. May I know the reason for this ambiguity? @cowtowncoder
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Jackson renames primitive boolean field by removing 'is'
In JSON, the key is coming as {"success": true} . I want the key as isSuccess itself. Is Jackson using the setter method...
Read more >JSON Serializer: Overviewing if Deleted is True - IntelliTect
Search for Serialization · Only select 'Id' and 'Deleted' from the database. · Pull all the data from the database, but set all...
Read more >Serialization Attributes - Json.NET
JsonPropertyAttribute - Placed on fields and properties to control how they should be serialized as a property in a JSON object.
Read more >Serialization Tutorial - GitHub Pages
A class map is a structure that defines the mapping between a class and a BSON document. It contains a list of the...
Read more >How to get json response only with an id of the related entity
Fix the deserialization issue. To help deserialize the task object properly, add the @JsonProperty annotation and specify the json object field ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try adding
to your lombok.config file. This will ensure that the generated getters and setters will also receive the
@JsonProperty
annotationThank you @WellingR !
I will close this issue as I do not see anything that can be done on Jackson side, but I hope this comment helps in working around such issue on Lombok side.