[英]Is the output of Gson.toJson repeatable on Map datatype
假設我有以下代碼段。
Gson gson = new Gson();
SortedMap<String,String> m = new TreeMap<String,String>();
m.put("a", "apple");
m.put("b", "box");
gson.toJson(m)
上面的代碼將輸出
{"a":"apple","b":"box"}
如果我執行代碼塊說100k次,是否保證可以返回相同的字符串?
是。 TreeMap條目根據其鍵的自然順序排序,並且gson會簡單地遍歷鍵集。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.