users@jersey.java.net

[Jersey] Re: Validating the JSON for put service

From: Petr Jurák <petr.jurak_at_gmail.com>
Date: Fri, 27 May 2011 21:25:17 +0200

Hi,

Validate against what? Do you have schema? If so, you should create custom
ContextResolver<JAXBContext> and in it use your own JAXBContext, which
should provide Unmarshaller (method createUnmarshaller) and Unmarshaller has
a method setSchema. This will enable validation.
Hope this helps.

BR, Petr

2011/5/27 viraj <raj_vid_at_yahoo.com>

> I am trying to implement *put* service where i will get a JSON as request,
> update the JAXB object and perform update in the database. Can you please
> suggest me how to validate the incoming JSON for its structure before
> performing the update.
>
> @*PUT*
> @Consumes(MediaType.APPLICATION_XML)
> public Response updatePerson(JAXBElement<Person> person) {
> // JSON VALIDATION HERE
> Person p = person.getValue();
> //update to the database
> ...
> }
>
> Thanks
> Viraj
> ------------------------------
> View this message in context: Validating the JSON for put service<http://jersey.576304.n2.nabble.com/Validating-the-JSON-for-put-service-tp6412109p6412109.html>
> Sent from the Jersey mailing list archive<http://jersey.576304.n2.nabble.com/>at Nabble.com.
>