我是新来的机器人。如何在安卓系统中过滤ArrayList
。我有以下的JSON response
,我想删除这些null objects
,请参考我的示例:
{
name: "7-11 上海店",
name_en: "7-11 Shanghai",
address: "浦东新区陆家嘴环路1396号",
address_en: "12344",
logo: "http://google.com/images/7eleven.gif",
items: [{
description: "(null)",
quantity: 0,
price: 0
},
{
description: "Item 1",
quantity: 1,
price: 19.9
}
],
amount_due: 19.9
}
在本例中,我要删除:
{
description: "(null)",
quantity: 0,
price: 0
}
提前感谢!
发布于 2013-09-12 06:24:31
我终于找到了答案。对于那些和我有同样问题的人。可以使用此解决方案删除array
上的特定项。
yourArray.removeAll(Collections.singleton("item_you_want_to_remove"));
e.g in my case:
myArray.removeAll(Collections.singleton("(null)"));
这很好用!
发布于 2013-09-12 06:20:45
您可以尝试使用GSON将json映射到一些Business类。这是谷歌的免费图书馆。链接到GSON
https://stackoverflow.com/questions/18756684
复制相似问题