Suppress wrapper object when serializing Java object into JSON using Jackson

后端 未结 5 2136
时光取名叫无心
时光取名叫无心 2021-02-15 00:02

I have a web service that returns a list as JSON. It uses Jackson to map a List of Java POJOs into JSON. The problem is that the JSON representation has a wrapper object around

5条回答
  •  别跟我提以往
    2021-02-15 00:38

    I stumbled upon this question while trying to solve the same problem, but was not using this with a @ResponseBody method, but was still encountering the "wrapper" in my serialized JSON. My solution was to add @JsonAnyGetter to the method/field, and then the wrapper would disappear from the JSON.

    Apparently this is a known Jackson bug/workaround: http://jira.codehaus.org/browse/JACKSON-765.

提交回复
热议问题