I have the following code:
@RequestMapping(value = "/checkInventory", consumes = "application/json", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<?> checkInventory (
// HEADERS
@RequestBody CheckInventoryRequest checkInventoryRequest) throws Exception {
// HEADERS LOGIC
CheckInventoryResponse checkInventoryResponse = new CheckInventoryResponse();
JSON
{
"supplier": "foo",
"supplierName": "ads",
"supplierLocation": "123",
"site": "goo",
"product": [
{
"lineItem": 1,
"manufacturer": "TEST",
"partNumber": "123",
},
{
"lineItem": 2,
"manufacturer": "TEST 2",
"partNumber": "3456",
}
]
}
I am able to populate the POJO with the regular values, but how do I make another ArrayList
using the product
part?
I need to do some database checking with the JSON
but I can't figure out how to save the ArrayList
.
heckInventoryResponse
import java.io.Serializable;
public class CheckInventoryResponse implements Serializable {
private String site;
private String supplier;
private String supplierLocation;
private String supplierName;
private String lineItem;
private String manufacturer;
private String partNumber;
public String getSite() {
return site;
}
public void setSite(String site) {
this.site = site;
}
public String getSupplier() {
return supplier;
}
public void setSupplier(String supplier) {
this.supplier = supplier;
}
public String getSupplierLocation() {
return supplierLocation;
}
public void setSupplierLocation(String supplierLocation) {
this.supplierLocation = supplierLocation;
}
public String getSupplierName() {
return supplierName;
}
public void setSupplierName(String supplierName) {
this.supplierName = supplierName;
}
public String getLineItem() {
return lineItem;
}
public void setLineItem(String lineItem) {
this.lineItem = lineItem;
}
public String getManufacturer() {
return manufacturer;
}
public void setManufacturer(String manufacturer) {
this.manufacturer = manufacturer;
}
public String getPartNumber() {
return partNumber;
}
public void setPartNumber(String partNumber) {
this.partNumber = partNumber;
}
}
This is my POJO class. It can be populated whenever my endpoint is being called, but I can't seem to figure out how to use the product part.