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]Bean对象反序列化失败 #1370

Closed
zacat opened this issue Apr 16, 2023 · 3 comments
Closed

[BUG]Bean对象反序列化失败 #1370

zacat opened this issue Apr 16, 2023 · 3 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@zacat
Copy link

zacat commented Apr 16, 2023

调置JSONReader.Feature.InitStringFieldAsEmpty的Feature情况下,执行了不该执行的字段。

  • OS信息: Windows 10
  • JDK信息:JDK17
  • 版本信息:Fastjson 2.28
   @Data
   @NoArgsConstructor
   static class TokenModel {
       String id;
       long createTime;
       Map<String, Object> dataMap = new ConcurrentHashMap<>();
       List<TokenSign> tokenSignList = new Vector<>();
   }

   public static void main(String[] args) {
       TokenModel tokenModel = new TokenModel();
       tokenModel.setId("token:login:session:10001");
       tokenModel.setCreateTime(1681578793249L);
       String str = JSON.toJSONString(tokenModel);
       System.out.println(str);
       tokenModel = JSON.parseObject(str, TokenModel.class, JSONReader.Feature.InitStringFieldAsEmpty);
       System.out.println(tokenModel);
   }
com.alibaba.fastjson2.JSONException: set dataMap error, not support type class java.lang.String
	at com.alibaba.fastjson2.reader.FieldReaderObjectField.accept(FieldReaderObjectField.java:228) ~[fastjson2-2.0.28.jar:?]
	at com.alibaba.fastjson2.reader.ObjectReaderAdapter.initStringFieldAsEmpty(ObjectReaderAdapter.java:536) ~[fastjson2-2.0.28.jar:?]

@zacat zacat added the bug Something isn't working label Apr 16, 2023
@wenshao wenshao added this to the 2.0.29 milestone Apr 16, 2023
@wenshao wenshao added the fixed label Apr 16, 2023
@wenshao
Copy link
Member

wenshao commented Apr 16, 2023

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.29-SNAPSHOT/
问题已经修复,请帮忙用2.0.29-SNAPSHOT版本验证。2.0.29版本预计在5月7日发布

@zacat
Copy link
Author

zacat commented Apr 17, 2023

谢谢。

@zacat zacat closed this as completed Apr 17, 2023
@wenshao
Copy link
Member

wenshao commented Apr 22, 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