From: Dave J <dev...@gm...> - 2015-03-13 18:05:17
|
Hello, After searching all over for info on this, I thought I would ask and see if anyone has tried this and possibly succeeded with it.... I have a POJO I set up to be provided as XML or JSON depending on the user's request. Class looks something like this... @XmlRootElement(name="aaa") public class AAA { .... } As XML it comes back fine, with the outermost tags being <aaa>....</aaa> However, when I add the @JsonRootName(value="aaa") at the same spot, I don't end up with JSON along the lines of {"aaa": .... } or "aaa": {} -- there is simply no mention of the intended "root element" and I end up with just { ... } I've seen a couple possibilities for dealing with this: - Jettison may deal with this annotation better than Jackson? - It is possible to extend JacksonJsonProvider, overriding the writeTo method, grab the mapper and set the SerializationFeature WRAP_ROOT_VALUE -- tried this, didn't have any joy Maybe I should start with, is there some reason this doesn't work out of the box like many other annotations do? Or perhaps I'm just using it wrong? Thanks so much. |