我正在创建一个RESTful API。
我正在进行@POST
电话,请求正文如下:
{
"user": "test1",
"animals": {
"cat": "3",
"dog": "5",
"cow": "10"
}
}
服务是:
@Path("/saveOwnerData")
@POST
@Produces({ "text/html", "application/json", "application/text" })
public Response saveOwnerData(OwnerData ownerData) {
//Save to db
}
实体对象:
@XmlRootElement
@Entity(value = "OwnerData", noClassnameStored = true)
public class OwnerData {
@Id
private String _id;
private String user;
private Map<String, String> animals;
public String get_id() {
return _id;
}
public void set_id(String _id) {
this._id = _id;
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public Map<String, String> getAnimals() {
return animals;
}
public void setAnimals(Map<String, String> animals) {
this.animals = animals;
}
}
问题:
感谢您的帮助。