If I understand your question as I think, to receive a JSON String in REST API, you can use a JAXB. You can refer the following.
REST API
@POST
@Path("addUser")
@Produces("text/plain")
@Consumes(MediaType.APPLICATION_JSON)
public String addUser(Student s) {
//Your logic here
return "user added";
};
JAXB representation for student.
public class Student {
String id;
String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
String age;
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public Student(String id, String name, String age) {
this.id = id;
this.name = name;
this.age = age;
}
public Student() {
}
}
When you post Student JSON String, you will get the Raw Student object in addUser method. Correct me, if my understanding is wrong.