I want to get distinct values from the list which contains duplicate values, there are 12 Key value pairs in the list row & I want to check only two key's values, depend on these two keys(PONumber,POCompliant) disctinct values should get.
[
{
"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!"
}]
I did like as per follows but it's not working.
Gson gson = new Gson();
ScanWarehouseReceiptResponse[] listArray = gson.fromJson(response.body().getResponseBody().getScanWarehouseRecieptResponse().getScanWarehouseRecieptResult(), ScanWarehouseReceiptResponse[].class);
List<ScanWarehouseReceiptResponse> al = new ArrayList<>();
al.addAll(asList(listArray));
Set<ScanWarehouseReceiptResponse> hs = new HashSet<>();
hs.addAll(al);
al.clear();
al.addAll(hs);