Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,18 @@ protected boolean shouldIgnoreField(FieldScope field) {
// other kinds of field ignorals are handled implicitly, i.e. are only available by way of being absent
return beanDescription.findProperties().stream()
.noneMatch(propertyDefinition -> declaredName.equals(propertyDefinition.getInternalName())
|| fieldName.equals(propertyDefinition.getInternalName()));
|| fieldName.equals(propertyDefinition.getInternalName())
|| fieldName.equals(toNonJavaBeanConformingName(propertyDefinition.getInternalName())));
}

private String toNonJavaBeanConformingName(String fieldName) {
// a field name like "xIndex" will have a propertyDefinition name "xindex", but should not be ignored.
if(fieldName == null || fieldName.length() < 2) {
return fieldName;
}
return fieldName.charAt(0)
+ fieldName.substring(1, 2).toUpperCase()
+ fieldName.substring(2);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ static Stream<Arguments> parametersForTestJsonIgnoreProperties() {
return Stream.of(
Arguments.of(SubType.class, "[includedChildField, includedParentField1, includedParentField2]"),
Arguments.of(SuperType.class, "[ignoredParentField2, includedParentField1]"),
Arguments.of(TypeWithUnderscoreField.class, "[import]")
Arguments.of(TypeWithUnderscoreField.class, "[import]"),
Arguments.of(TypeWithNonCompatibleGetter.class, "[aIncludedField2, included1]")
);
}

Expand Down Expand Up @@ -99,4 +100,15 @@ public String getIgnoredValue() {
return "method being ignored, because there is no matching field";
}
}

private static class TypeWithNonCompatibleGetter {
public String included1;

// @JsonProperty("aIncludedField2") // This will fix the test
private int aIncludedField2;

public int getAIncludedField2() {
return this.aIncludedField2;
}
}
}