I am trying to create JSON from a list of simple objects. It works, but my output is wrapped with the class name:
{"classname":[{"name":"John Doe","title":"manager"} .....]}
What I would like to have is
[{"name":"John Doe","title":"manager"} .....]
I understand this because I have @XmlRootElement in my class, but if I omit this, then I get an error:
A message body writer for Java class java.util.ArrayList, and Java type
java.util.List<MyClass>, and MIME media type application/json was not found
I set com.sun.jersey.api.json.POJOMappingFeature as true, although I'm not 100% sure if it is in the right place. I am using Embedded Jetty and I am setting a parameter for ServletHolder
source
share