FasterXML / FasterXML/jackson-databind

@JsonIgnoreProperties does not stack

Open
#1,037 10 comments 1 reaction 0 assignees View on GitHub
3.x
Dominant language
Java
Stars
3.7k
Forks
1.5k
Avg merge
3d 6h
Merged PRs (30d)
28

Description

I'd like to be able to aggregate `@JsonIgnoreProperties`, but it looks like it's only accepting the "top" one.

Here's a test case:

```
@JsonIgnoreProperties(value = { "generated" }, allowGetters = true)
static class BaseBean {
public String getGenerated() {
return "http://bar.com";
}
}

@JsonIgnoreProperties(value = { "computed" }, allowGetters = true)
static class ReadOnlyBean extends BaseBean {
public int getComputed() {
return 32;
}
}

@Test
public void testReadOnlyProp() throws Exception {

ObjectMapper m = new ObjectMapper();
String json = m.writeValueAsString(new ReadOnlyBean());
assertTrue(json.contains("generated"));
assertTrue(json.contains("computed"));
ReadOnlyBean bean = m.readValue(json, ReadOnlyBean.class);
assertNotNull(bean);
}
```

When the `@JsonIgnoreProperties` is on a mixin, the mixin's annotation trumps all.

Would it be possible to aggregate all the `@JsonIgnoreProperties`?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.