如题:比如我有这样一个JSON对象,怎么去除它的重复值?
{"element": [
"Name",
"Name",
"Name",
"Name",
"Description",
"Description",
"Description",
"Description",
"Facet"
]}
------解决方案--------------------
json倒是不知道怎么去除重复,不过其实可以转换一下,也可以得到你要的结果:把element转换成ArrayList数组
public static void removeDuplicate(ArrayList arlList)
{
HashSet h = new HashSet(arlList);
arlList.clear();
arlList.addAll(h);
}
然后再把数组加到JSON对象去,JSONObject object=new JSONObject();object.put("element",ArrayList);