rocketmq
rocketmq copied to clipboard
RocketMQ is producing non-standard-compliant JSON
RocketMQ uses 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,
Map<Integer, String> map = new HashMap<Integer, String>();
map.put(1, "abc");
map.put(2, "def");
System.out.println(RemotingSerializable.toJson(map, false));
generates
{1:"abc",2:"def"}
which does not comply with the JSON standard and may be validated in JSON Lint.
non-standard-compliant JSON can not be parsed by many JSON libraries, say JsonCpp, RapidJson, etc. It's mandatory to fix this.
Same issue in OffsetSerializeWrapper,
private ConcurrentMap<MessageQueue, AtomicLong> offsetTable = new ConcurrentHashMap<MessageQueue, AtomicLong>();
the key of offsetTable is MessageQueue object, but only string is accepted as object key in JSON standard.
https://github.com/alibaba/fastjson/issues/2078