{
"goods": [
{
"id": 12345,
"number": 10,
},
{
...
}
}
List<Long> goodsId = request.getGoods()
.stream()
.map(AddToShoppingCartItem::getId)
.collect(toList());
public static class AddToShoppingCartRequest {
List<AddToShoppingCartItem> goods;
public List<AddToShoppingCartItem> getGoods() {
return goods;
}
public void setGoods(List<AddToShoppingCartItem> goods) {
this.goods = goods;
}
}
public static class AddToShoppingCartItem {
long id;
int number;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
}
网友评论