Hello, I am using com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider to
generate a JSON output of my objects. However when a List has only one
element the JSON output I get is that of a single object and not a list of
objects.
For example if I have a List<User> users = new ArrayList() with only one
User object in this I get the following output:
"users" : { "username" : "hello" }
and not
"users" : [{"username" : "hello" }
I have been looking on the internet for a solution but could not find any
(using fasterxml jackson library was listed as a solution initself which is
why I am using it now). I initialise my JacksonJsonProvider as follows:
ObjectMapper mapper = new ObjectMapper();
return new JacksonJsonProvider(mapper);
And the list is annotated as follows:
@XmlElement(name="users")
List<User> users = new ArrayList<>();
What can I do to force JacksonJsonProvider to output a java.util.List
always as a list in JSON even when such list has only one element?
--
You received this message because you are subscribed to the Google Groups
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.