We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在实现IEnum接口的自定义枚举类中定义静态方法,导致json解析异常。
环境信息
枚举类:
import com.alibaba.fastjson2.annotation.JSONField; import com.baomidou.mybatisplus.annotation.EnumValue; import com.baomidou.mybatisplus.annotation.IEnum; public enum BizType implements IEnum<String> { COMMON("common", "通用"); BizType(String value, String name) { this.value = value; this.name = name; } @EnumValue private final String value; private final String name; @JSONField(value = true) public String getValue() { return value; } public String getName() { return name; } public static void test123() {} }
POJO:
import com.demo.test.entity.type.BizType; import lombok.Data; @Data public class VM { private BizType bizType; }
调用:
String str = "{\"bizType\":\"common\"}"; VM vm = JSON.parseObject(str, VM.class);
报错:
报错时的调试信息:
BizType.getValue()方法的返回类型被解析为java.io.Serializable,导致字段解析时,当成intValue在解析
尝试的修正方法
正常解析时的调试信息
项目压缩包 test.zip
补充信息 实际项目环境是,fastjson2-2.0.43 + jdk17 + mybatis-plus-3.5.4.1 半年前把jdk从8升级到17,当时测试没有问题,之后没有再运行过项目 本周再启动环境,出现上述报错 升级到新的版本fastjson2-2.0.51和mybatis-plus-3.5.6后,还是会出现上述报错
不确定是否由mybatis-plus引起, 调试时,由于com.alibaba.fastjson2.reader.ORG_1_35_VM.readObject(Unknown Source)无法跟进,问题定位不太方便
请项目维护人员帮忙看看,感谢感谢!
The text was updated successfully, but these errors were encountered:
fix change to isInt for ObjectReaderImplEnum, for issue #2682
801e1ae
b942ae9
https://github.com/alibaba/fastjson2/releases/tag/2.0.52 问题已修复,请用新版本
Sorry, something went wrong.
fix BeanUtils#getEnumValueField, for issue #2682 (#2821)
bcccf7b
* fix BeanUtils#getEnumValueField, for issue #2682 * fix #2821 * fix #2821
No branches or pull requests
请描述您的问题
在实现IEnum接口的自定义枚举类中定义静态方法,导致json解析异常。
环境信息
枚举类:
POJO:
调用:
报错:
报错时的调试信息:
BizType.getValue()方法的返回类型被解析为java.io.Serializable,导致字段解析时,当成intValue在解析
尝试的修正方法
正常解析时的调试信息
项目压缩包
test.zip
补充信息
实际项目环境是,fastjson2-2.0.43 + jdk17 + mybatis-plus-3.5.4.1
半年前把jdk从8升级到17,当时测试没有问题,之后没有再运行过项目
本周再启动环境,出现上述报错
升级到新的版本fastjson2-2.0.51和mybatis-plus-3.5.6后,还是会出现上述报错
不确定是否由mybatis-plus引起,
调试时,由于com.alibaba.fastjson2.reader.ORG_1_35_VM.readObject(Unknown Source)无法跟进,问题定位不太方便
请项目维护人员帮忙看看,感谢感谢!
The text was updated successfully, but these errors were encountered: