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

JSON.toJavaObject没有考虑@JSONField里的deserializeUsing的class #3060

Closed
helloqhx opened this issue Mar 12, 2020 · 3 comments
Closed
Assignees
Labels
Milestone

Comments

@helloqhx
Copy link

JSON.toJavaObject对于enum的field进行反序列化时,如果是int值,则不会考虑@JSONField里的信息,直接使用ordinal的值来反序列化了。

@helloqhx
Copy link
Author

helloqhx commented Mar 12, 2020

代码位置:TypeUtils里的1232~1238行:

if(obj instanceof Number){
                int ordinal = ((Number) obj).intValue();
                Object[] values = clazz.getEnumConstants();
                if(ordinal < values.length){
                    return (T) values[ordinal];
                }
}

@wenshao wenshao self-assigned this Mar 15, 2020
@wenshao wenshao added the bug label Mar 15, 2020
@wenshao wenshao added this to the 1.2.67 milestone Mar 15, 2020
@Omega-Ariston
Copy link
Collaborator

可以提供个简单的复现用例吗 :)

@wenshao
Copy link
Member

wenshao commented Jun 14, 2020

https://github.com/alibaba/fastjson/releases/tag/1.2.71
问题修复,请用新版本

@wenshao wenshao closed this as completed Jun 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants