How to send the JSON data in rest web services? I have a json object which contains product Id,store Id,price,product Unit,quantity values.Here All the values are integ
Your JSON input:
{
"productId": "p123",
"storeId": "s456",
"price": 12.34,
"productUnit": "u789",
"quantity": 42
}
The JAXB class:
@XmlRootElement
public class MyJaxbBean {
public String productId;
public String storeId;
public double price;
public String productUnit;
public int quantity;
public MyJaxbBean() {} // JAXB needs this
public MyJaxbBean(String productId, String storeId, double price, String productUnit, int quantity) {
// set members
}
}
The JAX-RS method.
@PUT
@Consumes("application/json")
public Response putMyBean(MyJaxbBean theInput) {
// Do something with theInput
return Response.created().build();
}
See the documentation of Jersey (the RI for JAX-RS) for details.