alibaba / alibaba/fastjson2

[QUESTION]FastJson2开启autoType数组类型丢失

Open
#3,154 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
4.4k
Forks
613
Avg merge
1d 22h
Merged PRs (30d)
6

Description

### 使用场景
使用Map接收参数,使用FastJson2序列化Map设置JSONWriter.Feature.WriteClassName, 以保存原始类类信息,序列化的字符串存储下来,在需要使用时取出反序列化,Map参数中所有value类型恢复为原来的类型

### 问题
测试发现,对于Object类型可以还原,但是对于数组类型(int[], byte[], List)无法还原出来,反序列化出来为JSONArray,对于无法明确知道用户传入的Object类型时,无法正确转换为对应的类型

### 测试代码
![json_case](https://github.com/user-attachments/assets/25d2a94b-abfa-40b3-8140-c02d2ab23cde)

#### 对比验证
测试了Jackson是可以还原的,对于基本类型数组、包装类型数组均可以还原

Contributor guide

Open the contributing guide

Research direction

Start with the attached test code and reproduce FastJson2 serialization of a Map using JSONWriter.Feature.WriteClassName, then deserialize values including int[], byte[], and List. Compare the result with the Jackson behavior shown in the issue; done means these array and collection values recover their original types instead of becoming JSONArray.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.