Thanks for your time, Mike.
So 5.2 of the Jersey User Guide (JAXB Based JSON support) is the way to
go - even if the web service only returns JSON (no XML)?
Carsten
On 09/18/2012 02:02 PM, Mike Summers wrote:
> This is really a JAXB question, but here goes:
> public class Person{
> private String firstName;
> private String lastName;
> }
>
> public class Persons{
> private List<Person> person;
> }
>
> Should start you to where you want to go;
>
> On Tue, Sep 18, 2012 at 3:58 AM, <carsten_at_byrman.demon.nl
> <mailto:carsten_at_byrman.demon.nl>> wrote:
>
> I am using Jersey's POJO mapping feature to map JSON responses to Java
> objects. This works, but I would like to have more control. For
> example, consider the following JSON, which uses arrays to
> minimize the
> payload:
>
> {
> "first_names": [
> "Ellen",
> ...
> ],
> "last_names": [
> "Ripley",
> ...
> ]
> }
>
> This can easily be mapped to:
>
> public class Persons {
>
> @JsonProperty("first_names")
> private List<String> firstNames;
> @JsonProperty("last_names")
> private List<String> firstNames;
>
> }
>
> However, I find this inconvenient and ugly. I would rather prefer
> somehow a list of Person POJOs, each one having a firstName and
> lastName as a String. Is this possible? Should I revert to low-level
> JSON support or can this be achieved via the POJO mapping feature?
>
> I have read the Jersey User Guide, but still have no clue on how to do
> this. I would be grateful if someone could point me in the right
> direction.
>
> Carsten
>
>