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
在具有实现接口的枚举上使用JSONField(value = true)注解,反序列化失效。
public interface BaseEnum { /** * 获取code * * @return {@link String} */ String getCode(); /** * 获取desc * * @return {@link String} */ String getDesc(); }
public enum Type implements BaseEnum{ X(101, "Big"), M(102, "Medium"), S(103, "Small"); private final int code; private final String name; Type(int code, String name) { this.code = code; this.name = name; } @JSONField(value = true) public String getCode() { return String.valueOf(code); } public String getName() { return name; } } public class Bean1 { public Type type; } @Test public void test1() { Bean1 bean = new Bean1(); bean.type = Type.M; String str = JSON.toJSONString(bean); assertEquals("{\"type\":102}", str); Bean1 bean1 = JSON.parseObject(str, Bean1.class); assertEquals(bean.type, bean1.type); }
The text was updated successfully, but these errors were encountered:
enum support String valueField, for issue #1435
1f4eb0c
https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.30-SNAPSHOT/ 帮忙用2.0.30-SNAPSHOT验证,2.0.30预计在周末(5月7日前)发布
Sorry, something went wrong.
https://github.com/alibaba/fastjson2/releases/tag/2.0.30 请用新版本
No branches or pull requests
在具有实现接口的枚举上使用JSONField(value = true)注解,反序列化失效。
The text was updated successfully, but these errors were encountered: