alibaba / alibaba/fastjson2

[BUG] 在处理 Map 对象反序列化时,没有严格按照 JSON 标准把 Long 的 key 加引号。

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

Description

根据 RFC 7159(JSON 标准),JSON 对象的 key 必须是字符串类型。

// 代码示例
```
Map map = new HashMap<>();
map.put(123456789012345678L, "value");
System.out.println(JSON.toJSONString(largeLongKeyMap));
```

// FastJSON2 输出
{123456789012345678:"value"}

// 标准 JSON 输出
{"123456789012345678":"value"}

测试版本 2.0.43

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the Map example and the reported FastJSON2 version, then trace the serialization path for map keys. Done means the output is valid JSON with the Long key quoted as a string and a regression test covers the case.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.