[BUG]将Map<Integer,String>对象序列化时没有生成正确的Json字符串
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
在将Map对象序列化时没有生成正确的Json字符串,生成的字符串中,键是不带引号的,这不符合JSON字符串的标准
### 环境信息
*请填写以下信息:*
- OS信息: [e.g.:Windows11]
- JDK信息: [e.g.:Openjdk 23.0.1]
- 版本信息:[e.g.:Fastjson2 2.0.56]
### 重现步骤
*如何操作可以重现该问题:*
1. `map.put(1, "管理员");
map.put(2, "普通用户");`
2. 使用 `JSON.toJSONString(map)` 方法
3. 输出字符串为 `{1:"管理员",2:"普通用户"}` 不符合JSON字符串格式
```java
Map map = new HashMap<>();
map.put(1, "管理员");
map.put(2, "普通用户");
String json = JSON.toJSONString(map);
System.out.println(json); // 输出 {1:"管理员",2:"普通用户"}(键无引号)
```
### 期待的正确结果
正确结果应该生成符合JSON字符串格式 如:{"1":"管理员","2":"普通用户"}
### 相关日志输出
*请复制并粘贴任何相关的日志输出。*
#### 附加信息

Contributor guide
Research direction
Start at the JSON.toJSONString(map) entry point and trace Map serialization. Reproduce the reported output with the example map, then add or update a regression test to verify that integer keys are quoted as JSON strings and that the resulting output matches the expected format.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100