Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I know @JsonProperty annotation can be used in the class of instance fields,which means in the view section what I want to show variable name, it is okay, but what if what annotation do we have to use to show the name of the class as I want in the view section?

For Example This is my dto class and I want to show in the view section like this:


Java
@Data
public class PlasticInfoDto {

    @JsonProperty("FirstName")
    private String firstName;

    @JsonProperty("LastName")
    private String lastName;

}



"PlasticInfo": {
"FirstName": "",
"LastName": ""
},

What I have tried:

I think using @JsonProperty annotation is may be can be used?
Posted
Comments
Richard Deeming 9-Dec-21 4:32am    
Your expected "JSON" output is not valid JSON. That would only work if the output was part of a parent object, in which case you would use @JsonProperty on the property/field in the parent class to determine the property name in the JSON output.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900