Hi Francesco
On 05/06/13 15:43, Francesco Chicchiriccò wrote:
Hi all,
I am currently trying to find the best way for implementing a RESTful
client for dealing with Atom entities (feed, entry, ...).
I've been building some examples using Webclient and I am pretty
satisfied, when using application/atom+xml:
List<Object> providers = new ArrayList<Object>();
providers.add(new AtomEntryProvider());
providers.add(new AtomFeedProvider());
WebClient client = WebClient.create(
"http://services.odata.org/v3/(S(sn4zeecdefwvblk2xxlk425x))/OData/OData.svc/Products",
providers);
Feed feed =
client.accept(MediaType.APPLICATION_ATOM_XML).get(Feed.class);
This just works, fine.
Now I'd like to be able to (de)serialize Feed (and Entry) instances via
application/json - unfortunately I could not manage to achieve this
using JacksonJaxbJsonProvider nor attempting to derive a custom provider
from Apache Wink's classes.
Any hint?
I've just checked again if
Abdera.getParserFactory().getParser("json");
would return something and as it happens it has still not been
implemented, so we can't update AtomEntryProvider and AtomFeedProvider
read Atom in JSON.
I have few old tests but they use JSONObject :-), something like this:
String jsonContent = webClient.accept("application/json").get(String.class);
JSONObject obj1 = new JSONObject(jsonContent);
but that probably won't help much if the feeds are complex, etc.
You may want to experiment with using JacksonJsonProvider (not
JAXB-aware) with your custom Feed model class, give it a try please
Cheers, Sergey
Regards.