Skip to content

Commit

Permalink
improved lambda function serialize support, for issue #1290
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Apr 12, 2023
1 parent 91d1f3e commit 5144961
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ boolean record = BeanUtils.isRecord(objectClass);
}
}

if (objectClass.getSuperclass() == Object.class && fieldWriters.isEmpty()) {
if (objectClass.getSuperclass() == Object.class) {
String simpleName = objectClass.getSimpleName();
if (simpleName.indexOf('$') != -1 && simpleName.contains("$$")) {
match = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,17 @@ public void test() {
public static class Bean {
public Object function;
}

@Test
public void test1() {
IntFunction function = (int i) -> Integer.valueOf(i);
Bean1 bean = new Bean1();
bean.functions = new Object[] {function};
String str = JSON.toJSONString(bean);
assertEquals("{\"functions\":[{}]}", str);
}

public static class Bean1 {
public Object[] functions;
}
}

0 comments on commit 5144961

Please sign in to comment.