-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fastjson2 在对LinkedHashMap做toJSONString时指定JSONWriter.Feature.MapSortField无效 #2318
Comments
这个结果不正是排序后的吗?底层是 Treemap 的自然排序 |
我demo复制错了,应该是LinedHashMap 指定了还是按放入顺序输出,未排序 |
lin
LinkedHashMap是按存放顺序排列的,你如果想按照 key 排序 就用 HashMap 别用LinkedHashMap |
我觉得这种设计就很奇怪,既然我用这个工具都需要使用方自己选数据类型决定排序了,那我干嘛不直接选用个TreeMap, 这个序列化的Feature参数有什么意义?或者干脆就不要叫MapSortField |
…g LinkedHashMap. Closes alibaba#2318
@rowstop 我主要有几个疑问
|
不用判断 你可以直接 new HashMap<>(map)就可以 |
我增加了一个Feature#SortMapEntriesByKeys,排序会包括LinkedHashMap,并且将MapSortField设置为deprecated。 请帮忙用2.0.48-SNAPSHOT验证,2.0.48正式版本预计在月末发布 |
使用2.0.15
输出
{"abc":1,"123":2}
key并未进行排序
The text was updated successfully, but these errors were encountered: