Gson serialize POJO with root value included?

前端 未结 4 1238
独厮守ぢ
独厮守ぢ 2020-12-29 22:52

I\'m having a problem serializing an object using Gson.

@XmlRootElement
class Foo implements Serializable {
    private int number;
    private String str;

         


        
4条回答
  •  我在风中等你
    2020-12-29 23:16

    If you are using Jackson api use the below lines

    mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);

提交回复
热议问题