Skip to content

@JsonProperty(access = Access.READ_ONLY) - unexpected behaviourΒ #935

@weaselmetal

Description

@weaselmetal

Hey,

I was hoping to make use of @JsonProperty(access = Access.READ_ONLY), but failed.

Assume this class:

public class TestPojo
{
    private String firstName;

    private String lastName;

    @JsonProperty(access = Access.READ_ONLY)
    public String getFullName()
    {
        return firstName + " " + lastName;
    }

    public String getFirstName()
    {
        return firstName;
    }

    public void setFirstName(String firstName)
    {
        this.firstName = firstName;
    }

    public String getLastName()
    {
        return lastName;
    }

    public void setLastName(String lastName)
    {
        this.lastName = lastName;
    }
}

I couldn't find a way to stop the deserializer from attempting to deserialize the field "fullName".
The only thing that helps is to create a setter and annotate it with @JsonIgnore. However, that setter does not make sense and I don't want to have it. Is this a bug in behaviour or am I missing something? Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions