[BUG]2.0.27 Feature.SupportAutoType map反序列化失败
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
Exception in thread "main" com.alibaba.fastjson.JSONException: not support name true
at com.alibaba.fastjson.JSON.parseObject(JSON.java:546)
at com.lorna.fastjson2.EnumJsonTest.main(EnumJsonTest.java:23)
Caused by: com.alibaba.fastjson2.JSONException: not support name true
at com.alibaba.fastjson2.reader.ObjectReaderImplMapTyped.readObject(ObjectReaderImplMapTyped.java:325)
at com.alibaba.fastjson2.reader.ORG_2_1_Test2.readObject(Unknown Source)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:536)
... 1 more
### 环境信息
- OS信息: [e.g.:mac os 14.2]
- JDK信息: [e.g.:jdk 1.8.0_212]
- 版本信息:[e.g.:Fastjson2 2.0.27]
### 重现步骤
public static void main(String[] args) {
String json2 = "{\"maps\":{\"true\":\"1\",\"false\":\"2\"}}";
Test2 test2 = JSON.parseObject(json2, Test2.class, Feature.SupportAutoType);
System.out.println(1);
}
private static class Test2 implements Serializable {
private Map maps;
public Map getMaps() {
return maps;
}
public void setMaps(Map maps) {
this.maps = maps;
}
}
### 期待的正确结果
序列化成功
### 相关日志输出
Exception in thread "main" com.alibaba.fastjson.JSONException: not support name true
at com.alibaba.fastjson.JSON.parseObject(JSON.java:546)
at com.lorna.fastjson2.EnumJsonTest.main(EnumJsonTest.java:23)
Caused by: com.alibaba.fastjson2.JSONException: not support name true
at com.alibaba.fastjson2.reader.ObjectReaderImplMapTyped.readObject(ObjectReaderImplMapTyped.java:325)
at com.alibaba.fastjson2.reader.ORG_2_1_Test2.readObject(Unknown Source)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:536)
... 1 more
Contributor guide
Research direction
Start with the provided Test2 reproducer and trace the failure from JSON.parseObject through ObjectReaderImplMapTyped.readObject at line 325. Confirm that the Boolean-keyed map containing "true" and "false" can be deserialized successfully without the not support name error.
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
- Clearly specified
- Newbie friendliness
- 35/100