This is the json i'm sending via POST request
{
"PIds" : [ "MOB123", "ELEC456"]
}
This is my class that receives the JSON,
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/GetProductsInfo")
public List<ProductDetails> getProductsInfo(ProductIds productIds) {
System.out.println(productIds + " ");
DBCursor<ProductDetails> dbCursor = collection.find(DBQuery.in("pid", productIds.getPIds()));
List<ProductDetails> products = new ArrayList<>();
while (dbCursor.hasNext()) {
ProductDetails product = dbCursor.next();
products.add(product);
}
return products;
}
Im converting the JSON array into the 'ProductIds' object, this is my POJO class
public class ProductIds
{
@JsonProperty("PIds")
private List<String> pIds;
public List<String> getPIds()
{
return pIds;
}
public void setPIds(List<String> Pids)
{
this.pIds = Pids;
}
@Override
public String toString()
{
return "ClassPojo [PIds = "+ pIds +"]";
}
}
The problem for me here is that the JSON is not getting populated into the java object 'productIds' is NULL, I dont know why. Im new to Jackson can someone help me out. Thank you