Skip to content
New issue

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

[BUG]JSONField注解bug #1258

Closed
MokerWill opened this issue Mar 21, 2023 · 2 comments
Closed

[BUG]JSONField注解bug #1258

MokerWill opened this issue Mar 21, 2023 · 2 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@MokerWill
Copy link

MokerWill commented Mar 21, 2023

问题描述

json string: {"e":"event", "E":1568879465651}
构造Bean.java

import com.alibaba.fastjson2.annotation.JSONField;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class Bean {
    @JSONField(name = "e")
    private String event;

    @JSONField(name = "E")
    private Long et;
}

json string反序列化为Bean正常,

JSONObject.parseObject(m, Bean.class);

将Bean.java改成SimpleBean.java

import com.alibaba.fastjson2.annotation.JSONField;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class SimpleBean {
    // @JSONField(name = "e")
    // private String event;

    @JSONField(name = "E")
    private Long et;
}

json string反序列化为SimpleBean

JSONObject.parseObject(m, SimpleBean.class);

抛异常:

com.alibaba.fastjson2.JSONException: parseLong error, value : event
	at com.alibaba.fastjson2.JSONReader.toInt64(JSONReader.java:2535)
	at com.alibaba.fastjson2.JSONReader.getInt64(JSONReader.java:656)
	at com.alibaba.fastjson2.JSONReaderUTF8.readInt64(JSONReaderUTF8.java:2266)
	at com.alibaba.fastjson2.reader.ORG_1_2_UMOrderUpdate.readObject(Unknown Source)
	at com.alibaba.fastjson2.JSON.parseObject(JSON.java:642)
	at com.alibaba.fastjson2.JSONObject.parseObject(JSONObject.java:1942)

环境信息

  • OS信息: Win10 Home
  • JDK信息: corretto-17.0.6
  • 版本信息:Fastjson2 2.0.26

重现步骤

见问题描述

期待的正确结果

json能够正常反序列化

相关日志输出

见问题描述

附加信息

@MokerWill MokerWill added the bug Something isn't working label Mar 21, 2023
@MokerWill MokerWill changed the title [BUG] [BUG]JSONField注解bug Mar 21, 2023
@wenshao wenshao added this to the 2.0.27 milestone Apr 2, 2023
@wenshao
Copy link
Member

wenshao commented Apr 2, 2023

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.27-SNAPSHOT/
问题已修复,请帮忙用2.0.27-SNAPSHOT版本验证

@wenshao wenshao added the fixed label Apr 2, 2023
@wenshao
Copy link
Member

wenshao commented Apr 8, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants