0

I'm trying to process an incoming request that is a JSON. The code below is a sample:

@Post
@Path("somePath")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response myService(requestDTO requestBody){
        //Doing Stuff
}

My DTO class is essentially this:

@JsonInclude(Include.NON_EMPTY)
public class RequestDTO{
    private Object object;

    public Object getter(){}
    public void setter(){}
}

My question is how does the @Consumes annotation know to take the information in the request JSON and place it into the object of my DTO? How would this work if I had multiple variables in my DTO? Or multiple levels in my request body (Object inside Objects, etc)?

Sorry for such a general question, but I'm having a hard time understanding this.

Thanks.

Brodiman
  • 149
  • 2
  • 9

1 Answers1

0

I was able to answer my own question. This answer here is a good explanation of how to properly use the @Consumes annotation.

How to consume json parameter in java restful service

Brodiman
  • 149
  • 2
  • 9