users@jersey.java.net

[Jersey] Re: Jersey with Jackson for JSON

From: Sven Strittmatter <weltraumschaf_at_googlemail.com>
Date: Mon, 20 Jun 2011 13:57:09 +0200

Hi,

sorry that I didn't answer. The missing keyword for me was Jackson. I've
searched the infos on the wrong place (Jersy). For now playing around I
just use this:
ClientResponse response = webResource.get(ClientResponse.class);
ObjectMapper mapper = new ObjectMapper();
Map<String,Object> data =
mapper.readValue(response.getEntity(String.class), Map.class);

But one thing I struggled: When The JSON has a toplevel array literal
then Jackson does notlike that:
Map<String,Object> data = mapper.readValue("[{...},{...}...], Map.class)

While I'm writing this it began to dawn on me that Map<String,Object>
may be is wrong for an JSON array with objects inside, right? I should
try Object[] data = mapper.readValue("[{...},{...}...], Map.class)

regards
sven