mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -33,10 +33,7 @@ public class CustomSerializeTest {
|
||||
public void init() {
|
||||
TypeAdapterManager.getInstance().register(CustomBean.class,
|
||||
(JSONSerializer<CustomBean>) (bean, context) ->{
|
||||
JSONObject contextJson = (JSONObject) context.getContextJson();
|
||||
if(null == contextJson){
|
||||
contextJson = JSONUtil.ofObj(context.config());
|
||||
}
|
||||
final JSONObject contextJson = context.getOrCreateObj();
|
||||
return contextJson.set("customName", bean.name);
|
||||
});
|
||||
}
|
||||
|
@@ -57,7 +57,7 @@ public class Issue2555Test {
|
||||
public static class MySerializer implements JSONSerializer<MyType> {
|
||||
@Override
|
||||
public JSON serialize(final MyType bean, final JSONContext context) {
|
||||
return ((JSONObject)context.getContextJson()).set("addr", bean.getAddress());
|
||||
return context.getOrCreateObj().set("addr", bean.getAddress());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -70,12 +70,7 @@ public class Issue3086Test {
|
||||
public JSON serialize(final TestBean bean, final JSONContext context) {
|
||||
final List<String> strings = bean.getAuthorities()
|
||||
.stream().map(SimpleGrantedAuthority::getAuthority).collect(Collectors.toList());
|
||||
JSONObject contextJson = (JSONObject) context.getContextJson();
|
||||
if(null == contextJson){
|
||||
contextJson = new JSONObject(context.config());
|
||||
}
|
||||
contextJson.set("authorities",strings);
|
||||
return contextJson;
|
||||
return context.getOrCreateObj().set("authorities",strings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user