On Mon, Jun 20, 2011 at 4:57 AM, Sven Strittmatter
<weltraumschaf_at_googlemail.com> wrote:
> 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)
That wouldn't quite work, since Object[] != Map<?,?>.
So if it is Object (as in, Lists, Maps etc) array that you want, what
you'd use is:
Object[] data = mapper.readValue("...", Object[].class);
-+ Tatu +-