lundi 8 juin 2015

JAX-RS Custom JSON representation of primitive Resource return type

Suppose we have a service with the following contract:

public interface CategoryService {

    public int createNew(String languageCode, String name, String descriptionMarkdown, Integer parentCategoryID, String createdByUserName) throws ServiceException;

};

How do I map the int return type to produce a JSON value like the following?

PS: I know that the createNew method will have to be an HTTP POST request (annotation @POST). Assumes annotations are there. I just need the response representation.

{"id": 1}

Aucun commentaire:

Enregistrer un commentaire