users@jersey.java.net

Re: [Jersey] JSON Arrays issue in Pet Catalog sample app

From: Gautam Arora <gautamsarora_at_gatech.edu>
Date: Sun, 1 Mar 2009 22:11:11 -0800 (PST)

update:

1. I moved to Jersey 1.0.2 (downloaded it and added to netbeans)
2. Edited the UriResolver.resolve() method
original: JAXBContext context = JAXBContext.newInstance(type);
modified: JAXBContext context = new
JSONJAXBContext(JSONConfiguration.mapped().rootUnwrapping(true).arrays("items").build(),type);

This was as per the steps given at
http://blogs.sun.com/japod/entry/configuring_json_for_restful_web

But the root element is still getting dropped. Any tips on how to make this
work with this app?

Gautam


Gautam Arora wrote:
>
> Hi,
> I'm following the RESTful Pet Catalog tutorial from
> http://weblogs.java.net/blog/caroljmcdonald/archive/2008/08/a_restful_pet_c_1.html
>
> The expected JSON response (as per the tutorial is)
> http://localhost:8080/catalog/resources/items/
>
> {"items":{"@uri":"http://localhost:8080/catalog/resources/items","item":[{
> etc etc
>
> but I get the response as:
> {"@uri":"http://localhost:8080/catalog/resources/items","item":[{ etc etc
>
> The "items" label is dropped.
> I've read here on forum posts that say that dropping off the root element
> is a desired feature and with newer releases of jersey it should be
> fixed(/configurable?)
>
> I've developed the app myself and also tested the same app by downloading
> it and running it and and running into the same issue.
>
> I'm using Jersey 1.0. Is this issue fixed in 1.0.2?
>
> Whats the best way to make jersey1.0 generate the "items" label for this
> app? I've read on posts that we need to add a property for the json
> unwrapping but cant figure out where/how to put it in the pet catalog
> sample app.
>
> I need this as I'm using YUI which expects this and throws an invalid
> label error otherwise
> As per the tutorial, having the label is the expected behavior, so any
> reasons why I could be missing it?
>
> Thanks,
> Gautam
>

-- 
View this message in context: http://n2.nabble.com/JSON-Arrays-issue-in-Pet-Catalog-sample-app-tp2406690p2407726.html
Sent from the Jersey mailing list archive at Nabble.com.