修复BeanUtil.copyProperties中mapToMap时key被转为String问题

This commit is contained in:
Looly
2024-07-06 11:36:34 +08:00
parent 2fffc07c0f
commit ca16ad9f1d
15 changed files with 84 additions and 33 deletions

View File

@@ -208,7 +208,9 @@ public class JSONObjectMapper {
private void mapFromBean(final Object bean, final JSONObject jsonObject) {
final CopyOptions copyOptions = InternalJSONUtil.toCopyOptions(jsonObject.config());
if (null != this.predicate) {
copyOptions.setFieldEditor((entry -> this.predicate.test(entry) ? entry : null));
copyOptions.setFieldEditor((entry -> this.predicate.test(
MutableEntry.of(StrUtil.toStringOrNull(entry.getKey()), entry.getValue())) ?
entry : null));
}
BeanUtil.beanToMap(bean, jsonObject, copyOptions);
}