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
参考了 https://alibaba.github.io/fastjson2/annotations_cn.html "1.6 通过JSONField(value = true)配置 ..." 进行enum的解析,但是不成功。
更具体地,如果先进行一次序列化(结果不储存到任何变量),再进行反序列化,则成功;直接进行反序列化,则不成功。可以直接用以下测试用例进行复现。
请填写以下信息:
package com.bytedance.data.edc.pricecmp.rulecore.domain.services; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.annotation.JSONField; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; public class FastJsonTest { // failure @Test public void intEnumDeserialize1() { Bean1 bean1 = JSON.parseObject("{\"type\":102}", Bean1.class); assertEquals(102, bean1.type.getCode()); } // success @Test public void intEnumDeserialize2() { // add this { Bean1 bean = new Bean1(); bean.type = Type.S; JSON.toJSONString(bean); } intEnumDeserialize1(); } } class Bean1 { public Type type; } enum Type { X(101), M(102), S(103); private final int code; Type(int code) { this.code = code; } @JSONField(value = true) public int getCode() { return code; } }
对您期望发生的结果进行清晰简洁的描述。
请复制并粘贴任何相关的日志输出。
如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。
The text was updated successfully, but these errors were encountered:
fix non public enum deserialize error, for issue #2154
37a1dc8
https://github.com/alibaba/fastjson2/releases/tag/2.0.45 问题已修复,请用新版本
Sorry, something went wrong.
No branches or pull requests
问题描述
参考了 https://alibaba.github.io/fastjson2/annotations_cn.html "1.6 通过JSONField(value = true)配置 ..." 进行enum的解析,但是不成功。
更具体地,如果先进行一次序列化(结果不储存到任何变量),再进行反序列化,则成功;直接进行反序列化,则不成功。可以直接用以下测试用例进行复现。
环境信息
请填写以下信息:
重现步骤
期待的正确结果
对您期望发生的结果进行清晰简洁的描述。
相关日志输出
请复制并粘贴任何相关的日志输出。
附加信息
如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。
The text was updated successfully, but these errors were encountered: