Java Gson Exclude fields during serialization

前端 未结 7 1617
走了就别回头了
走了就别回头了 2020-12-10 01:48

I have a ConfigInstance class which contains a password and a password_hash. Now I want to serialize the object using gson but exclude

7条回答
  •  旧巷少年郎
    2020-12-10 02:06

    If you want to disable only serialization or only deserialization, you can play with @Expose annotation's attributes, e.g.:

    @Expose(serialize = false, deserialize = true)
    

    Default option is true, so deserialize is unnecessary here.

提交回复
热议问题