mardi 12 mai 2015

Converting data sent from the client with RESTeasy

I am developing some REST services, in J2EE environment, using RESTeasy library. If I have this @POST REST method:

@POST
@Path("/filter")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public List<Order> findOrders(
        @FormParam("orderfiltercriteria") OrderFilterCriteria orderFilterCriteria, 
        @FormParam("readcontext") OrderReadContext readContext, 
        @FormParam("querycontrol") QueryControl queryControl, 
        @FormParam("fetchpattern") FetchPattern fetchPattern, 
        @FormParam("loadpattern") LoadPattern loadPattern)
{
    ...
}

Supposing that the client sends these data through a form, and supposing that these are JSON string, how can I convert (server-side) these JSON strings in the correct way? For example, the JSON string for "readcontext" field, how can be converted properly into the OrderReadContext object?

I am using WidlFly 8.2 for the deploy. Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire