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

枚举类型自定义反序列化,调用readObejct时传入targetClass,用于反序列化具体的枚举[FEATURE] #2329

Closed
ljj18 opened this issue Mar 15, 2024 · 3 comments
Labels
enhancement New feature or request fixed
Milestone

Comments

@ljj18
Copy link

ljj18 commented Mar 15, 2024

请描述您的需求或者改进建议

枚举类型自定义反序列化,调用readObejct时传入targetClass,用于反序列化具体的枚举

请描述你建议的实现方案

com.alibaba.fastjson2.util.TypeUtils.cast方法(第1501行)
原代码:
return (T) objectReader.readObject(jsonReader, null, null, 0);
建议改为:
return (T) objectReader.readObject(jsonReader, targetClass, null, 0);
这样就可以具体的枚举

描述您考虑过的替代方案

对您考虑过的任何替代解决方案或功能的描述。

附加信息

版本: V2.0.46
反序列化是采用JSONType注解到枚举类
@jsontype(serializer = DictSerializer.class, deserializer = DictDeserializer.class, writeEnumAsJavaBean = true)
public enum AuthStrengthType implements IDict

@ljj18 ljj18 added the enhancement New feature or request label Mar 15, 2024
@wenshao
Copy link
Member

wenshao commented Mar 17, 2024

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

@wenshao wenshao added the fixed label Mar 17, 2024
@wenshao wenshao added this to the 2.0.48 milestone Mar 17, 2024
@wenshao
Copy link
Member

wenshao commented Mar 25, 2024

@wenshao wenshao closed this as completed Mar 25, 2024
@ljj18
Copy link
Author

ljj18 commented Apr 3, 2024

已测试,功能已实现

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed
Projects
None yet
Development

No branches or pull requests

2 participants