Java.util.Map to JSON Object with Jersey / JAXB / Jackson

前端 未结 4 962
遥遥无期
遥遥无期 2020-12-08 01:06

I\'ve been trying to create a Jersey REST Webservice. I want to receive and emit JSON objects from Java classes like the following:

@XmlRootElement
public cl         


        
4条回答
  •  伪装坚强ぢ
    2020-12-08 01:43

    I don't know why this isn't the default setting, and it took me a while figuring it out, but if you want working JSON conversion with Jersey, add

        
            com.sun.jersey.api.json.POJOMappingFeature
            true
        
    

    to your web.xml and all your problems should be solved.

    PS: you also need to get rid of the @XmlRootElement annotations to make it work

提交回复
热议问题