This commit is contained in:
Looly 2024-12-09 20:47:12 +08:00
parent 8fd770fe4d
commit b6b8c28db8

View File

@ -0,0 +1,38 @@
package cn.hutool.json;
import cn.hutool.json.serialize.GlobalSerializeMapping;
import cn.hutool.json.serialize.JSONObjectSerializer;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class IssueIB9MH0Test {
@Test
void parseTest() {
GlobalSerializeMapping.put(TabTypeEnum.class, (JSONObjectSerializer<TabTypeEnum>) (json, bean) -> json.set("code", bean.getCode())
.set("title", bean.getTitle()));
final JSON parse = JSONUtil.parse(TabTypeEnum._01);
Assertions.assertEquals("{\"code\":\"tab_people_home\",\"title\":\"首页\"}", parse.toString());
}
public enum TabTypeEnum {
_01("tab_people_home","首页"),
_02("tab_people_hospital","医院");
private String code;
private String title;
TabTypeEnum(String code, String title) {
this.code = code;
this.title = title;
}
public String getCode() {
return code;
}
public String getTitle() {
return title;
}
}
}