RocketMQ is producing non-standard-compliant JSON
- Dominant language
- Java
- Stars
- 22.6k
- Forks
- 12k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 26
Description
RocketMQ uses [fastjson](https://github.com/alibaba/fastjson) to serialize object to JSON text.
Unfortunately, with the default configuration, the FastJson library does not respect the JSON standard as expected, which imposes an enormous obstacle for other languages to talk to RocketMQ.
For example,
```java
Map map = new HashMap();
map.put(1, "abc");
map.put(2, "def");
System.out.println(RemotingSerializable.toJson(map, false));
```
generates
```text
{1:"abc",2:"def"}
```
which does not comply with the JSON standard and may be validated in [JSON Lint](https://jsonlint.com/).
non-standard-compliant JSON can not be parsed by many JSON libraries, say JsonCpp, RapidJson, etc. It's mandatory to fix this.
Contributor guide
Research direction
Start by locating RemotingSerializable.toJson and inspect how fastjson is configured for serialization. Reproduce the issue with the Integer-to-String map shown in the report, then validate the output with JSON Lint or a JSON library such as JsonCpp; done means the generated object uses standard-compliant JSON syntax.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100