-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
1.2.3版後 JSONObject.toJSONString回傳的字串不再依key值排序了 #359
Comments
try this.
|
在我這個案例中,並不存在需要反序列化的java物件,也就沒有地方可以放annotation |
原来是将其他类型的Map转为TreeMap再序列化,这样开销较大,如果需要,用ValueFilter将Map转成TreeMap。 |
wenshao提供的ValueFilter方式,僅能調整value物件 |
LinkedHashMap<String, Object> root=JSON.parseObject(map.toString(),new TypeReference<LinkedHashMap<String, Object>>(){} ); 这样对于单map对象可以解决顺序问题,嵌套的map还没有尝试,不过这可以是一种解决方法,希望对你有帮助@limhi |
That is good |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
即便使用了 SerializerFeature.SortField 亦得到錯誤結果
測試程式:
使用1.2.2版時輸出 => 正常
使用1.2.3~1.2.6版時輸出 => 亂序
The text was updated successfully, but these errors were encountered: