Total Pageviews


[jackson] How to rename JSON attribute name

I would like to create a Java Bean to do mapping with JSON object.
But the JSON object has an attribute name, public, which has conflict with Java, because public is an reserved word in Java. How to handle this problem?

You can utilize @JsonProperty to rename it.
The Java bean looks like (publicStr is mapping to public in JSON):
    public static class DsnDto {
        private String publicStr;
        private String secret;
        private String csp;


No comments: