We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
在使用2.0.57版本 com.alibaba.fastjson2.JSONObject#from(java.lang.Object) 将含有泛型的java bean 转换为 JSONObject时,返回的结果中泛型数据为空的JSONObject
com.alibaba.fastjson2.JSONObject#from(java.lang.Object)
<!-- https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2 --> <dependency> <groupId>com.alibaba.fastjson2</groupId> <artifactId>fastjson2</artifactId> <version>2.0.57</version> </dependency>
{}
@Data @AllArgsConstructor public static class TestClass<T> { private T generic; private Long testLong; } public static void main(String[] args) { TestClass<String> testClass = new TestClass<>("hello", 1L); JSONObject jsonObject = JSONObject.from(testClass); System.out.println(jsonObject.toString()); // Generic丢失 {"generic":{},"testLong":1} }
预期返回:{"generic":"hello","testLong":1}
{"generic":"hello","testLong":1}
疑问:我对 com.alibaba.fastjson2.JSONObject#from(java.lang.Object)的用法是正确的吗?使用fastjson2将java bean转换为JSONObject时候,推荐的做法是什么?
2.0.56版本没有这个问题。
The text was updated successfully, but these errors were encountered:
既然2.0.56版本没有这个问题,那应该就是2.0.57的bug,我去研究一下
Sorry, something went wrong.
Update ObjectWriterAdapter.java
905f123
fix bug for issue alibaba#3569
Add files via upload
6b38051
b5f9fbb
8ea06bf
fix bug for issue #3569 (#3574)
d509225
jujn
No branches or pull requests
问题描述
在使用2.0.57版本
com.alibaba.fastjson2.JSONObject#from(java.lang.Object)
将含有泛型的java bean 转换为 JSONObject时,返回的结果中泛型数据为空的JSONObject环境信息
重现步骤
com.alibaba.fastjson2.JSONObject#from(java.lang.Object)
方法{}
错误期待的正确结果
预期返回:
{"generic":"hello","testLong":1}
疑问:我对
com.alibaba.fastjson2.JSONObject#from(java.lang.Object)
的用法是正确的吗?使用fastjson2将java bean转换为JSONObject时候,推荐的做法是什么?附加信息
2.0.56版本没有这个问题。
The text was updated successfully, but these errors were encountered: