Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@JsonProperty(access = Access.READ_ONLY) does not work

See original GitHub issue

Fails to work with 2.11.1

Test to reproduce the issue:

public class Bug {
    public static void main(String[] args) throws JsonProcessingException {
        ObjectMapper objectMapper = new ObjectMapper();
        Bean bean = new Bean();

        String json = objectMapper.writeValueAsString(bean);
        Bean newBean = objectMapper.readValue(json, Bean.class);

import com.fasterxml.jackson.annotation.JsonProperty;

public class Bean {

    private String works;

    @JsonProperty(value = "t", access = JsonProperty.Access.READ_ONLY)
    public String getDoesntWork() {
        return "pleaseFixThisBug";

    public String getWorks() {
        return works;

    public void setWorks(String works) { = works;


Exception in thread "main" com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "t" (class Bean), not marked as ignorable (one known property: "works"])
 at [Source: (String)"{"works":"works","t":"pleaseFixThisBug"}"; line: 1, column: 23] (through reference chain: Bean["t"])
	at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(
	at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(
	at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(
	at Bug.main(

Expected behaviour: The property should only be serialized. However, it is being tried to deserialized.

This bug was supposed to be fixed with

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

RakshithVPcommented, Aug 12, 2020

May I know when is the release of 2.12.0 planned?

cowtowncodercommented, Aug 12, 2020

@RakshithVP earlier I was hoping to get release out by September 2020, but that may slip – I still hope the first release candidate would be out in september.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JsonProperty.Access.READ_ONLY not work #1805 - GitHub
Then I tried JsonIgnoreProperties, and annotate the class with specified field, jackson ignores the field and works as expected.
Read more >
Jackson read-only property in method - Stack Overflow
I tried @JsonIgnoreProperty , @JsonGetter and @JsonProperty(access = JsonProperty. Access. READ_ONLY) on the method but nothing works.
Read more >
JsonProperty.Access (Jackson-annotations 2.6.0 API)
Access setting that means that the property may only be read for serialization, but not written (set) during deserialization. WRITE_ONLY. public static final ......
Read more >
Jackson Readonly properties and swagger UI
If the property is marking as readonly, it will be ignored when something is posted, but it will be available on the response....
Read more >
Best bits of Jackson 2.6 - cowtowncoder - Medium
AUTO: Default visibility rules are used, setter/getter may or may not be visible (default value for `@JsonProperty.access`. JsonPointer-filtering for JsonParser ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found