【问题标题】:how to get distinct values from the list in android如何从android中的列表中获取不同的值
【发布时间】:2018-03-03 15:28:06
【问题描述】:

我想从包含重复值的列表中获取不同的值,列表行中有 12 个键值对,我只想检查两个键的值,取决于这两个键(PONumber,POCompliant)不同的值应该得到。

    [
{
"WR":"234860",
"Pieces":1,
"POCompliant":"YES!",
"PONumber":"SONYAR2435",
"ItemLookupCode":"SO_1_9490410_68",
"Description":"HANS 27495821",
"PriceCheck":"OK!",
"CostCheck":"Item Cost Missing!",
"BarcodeCheck":"10Digit Barcode Missing",
"NegativeQtyCheck":"OK!",
"InactiveCheck":"OK!",
"DoNotOrderCheck":"OK!"
},
{
"WR":"234860",
"Pieces":1,
"POCompliant":"YES!",
"PONumber":"SONYAR2435",
"ItemLookupCode":"SO_1_9490410_69",
"Description":"HANS 06462860",
"PriceCheck":"OK!",
"CostCheck":"Item Cost Missing!",
"BarcodeCheck":"10Digit Barcode Missing",
"NegativeQtyCheck":"OK!",
"InactiveCheck":"OK!",
"DoNotOrderCheck":"OK!"
}]

我确实喜欢以下内容,但它不起作用。

Gson gson = new Gson(); 
ScanWarehouseReceiptResponse[] listArray = gson.fromJson(response.body().getResponseBody().getScanWareh‌​ouseRecieptResponse(‌​).getScanWarehouseRe‌​cieptResult(), ScanWarehouseReceiptResponse[].class); 
    List<ScanWarehouseReceiptResponse> al = new ArrayList<>();
    al.addAll(asList(listArray));
    Set<ScanWarehouseReceiptResponse> hs = new HashSet<>();
    hs.addAll(al);
    al.clear();
    al.addAll(hs);

【问题讨论】:

  • 将您的响应转换为模型类,为此您可以使用 GSON。然后拿走你想要的钥匙
  • 检查this。会有帮助的

标签: java android arrays json


【解决方案1】:

查询: 选择不同的 (PO 编号,符合 PO) 从 表名;

【讨论】:

  • 这是我从服务中得到的响应,我想在移动设备上对客户端方式进行排序。
猜你喜欢
  • 2020-07-13
  • 2013-02-11
  • 2023-03-08
  • 2017-03-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-19
相关资源
最近更新 更多