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]枚举反序列化异常 2.0.32 #1500

Closed
kaizen84 opened this issue May 19, 2023 · 4 comments
Closed

[BUG]枚举反序列化异常 2.0.32 #1500

kaizen84 opened this issue May 19, 2023 · 4 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@kaizen84
Copy link

复现代码

import com.alibaba.fastjson2.*;
import com.alibaba.fastjson2.util.ParameterizedTypeImpl;
import org.junit.Test;

import java.util.List;

/**
 * @author 张治保
 * date 2023/5/8
 */
public class FastjsonTest {
    @Test
    public void test() {
        List<TestEnum> enums = List.of(TestEnum.A, TestEnum.B);
        JSONArray array = JSON.parseArray(JSON.toJSONString(enums));
        List<TestEnum> result = array.to(new ParameterizedTypeImpl(new Class[]{TestEnum.class}, null, List.class));
    }

    enum TestEnum {
        A,
        B
    }


}

异常

com.alibaba.fastjson2.JSONException: can not convert from class java.lang.String to class top.rows.dubbo.test.consumer.FastjsonTest$TestEnum

	at com.alibaba.fastjson2.reader.ObjectReaderImplList.createInstance(ObjectReaderImplList.java:251)
	at com.alibaba.fastjson2.JSONArray.to(JSONArray.java:983)
	at top.rows.dubbo.test.consumer.FastjsonTest.test(FastjsonTest.java:18)
@kaizen84 kaizen84 added the bug Something isn't working label May 19, 2023
@kaizen84 kaizen84 changed the title [BUG]枚举发序列化异常 2.0.32 [BUG]枚举序列化异常 2.0.32 May 19, 2023
@kaizen84
Copy link
Author

kaizen84 commented May 19, 2023

com.alibaba.fastjson2.reader.ObjectReaderImplList#createInstance(java.util.Collection)

image

@kaizen84 kaizen84 changed the title [BUG]枚举序列化异常 2.0.32 [BUG]枚举反序列化异常 2.0.32 May 19, 2023
@wenshao wenshao added this to the 2.0.33 milestone May 19, 2023
@wenshao
Copy link
Member

wenshao commented May 19, 2023

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

@wenshao wenshao added the fixed label May 19, 2023
@kaizen84
Copy link
Author

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

已通过验证

@wenshao
Copy link
Member

wenshao commented May 29, 2023

@wenshao wenshao closed this as completed May 29, 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