[BUG]使用fastjson2(2.0.47)序列化后json串出现了两个@type 导致fastjson1(1.2.83)版本反序列化丢失属性
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
*使用fastjson2(2.0.47)序列化后json串出现了两个@type 导致fastjson1(1.2.83)版本反序列化丢失属性*

### 环境信息
*请填写以下信息:*
- OS信息: [e.g.:Mac os 14.2.1]
- JDK信息: [e.g.:jdk 1.8.0_312]
- 版本信息:[e.g.:Fastjson2 2.0.47]
### 重现步骤
*如何操作可以重现该问题:*
1、使用fastjson2(2.0.47)序列化后json串出现了两个@type 导致fastjson1(1.2.83)版本反序列化丢失属性
2、反序列化后map接口中只有一个属性“xxx”
```java
@Test
public void test() {
List result = new ArrayList<>();
A a = new A();
a.setA("a");
Map m = new HashMap<>();
m.put("k1", "v1");
m.put("k2", "v2");
m.put("k3", "v3");
m.put("k4", "v4");
m.put("k5", "v5");
a.setM(m);
result.add(a);
String json = JSON.toJSONString(result, SerializerFeature.WriteClassName);
@Data
public static class A {
private String a;
private Map m;
}
```
### 期待的正确结果
正确序列化
### 相关日志输出
无报错
Contributor guide
Research direction
Start with the supplied Java test and inspect the WriteClassName serialization and parseArray round trip across fastjson2 2.0.47 and fastjson1 1.2.83. Compare the generated JSON and the deserialized map contents; done means the round trip preserves all map properties and emits only one java.util.HashMap type marker.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100