Excluding certain fields from Serialization based on value in GSON
问题 I am using GSON for my serialization purposes, I am not finding a way of excluding certain fields from serialization based on ExclusionStrategy class provided by Gson based on the value of field, as it only supports top level class or field attributes based exclusions. The field attributes do not include the value of that field. So what should I do? 回答1: The way to achieve this is by creating custom serializer for the class in question. After allowing Gson to create a JSON object in default