Convert JSON query parameters to objects with JAX-RS

Posted by deamon on Stack Overflow See other posts from Stack Overflow or by deamon
Published on 2010-04-23T09:40:45Z Indexed on 2010/04/23 9:43 UTC
Read the original article Hit count: 450

Filed under:
|
|
|
|

I have a JAX-RS resource, which gets its paramaters as a JSON string like this:

http://some.test/aresource?query={"paramA":"value1", "paramB":"value2"}

The reason to use JSON here, is that the query object can be quite complex in real use cases.

I'd like to convert the JSON string to a Java object, dto in the example:

@GET 
@Produces("text/plain")
public String getIt(@QueryParam("query") DataTransferObject dto ) {
    ...
}

Does JAX-RS support such a conversion from JSON passed as a query param to Java objects?

© Stack Overflow or respective owner

Related posts about jax-rs

Related posts about JSON