JsonProperty not working while minification enabled

Viewed 916

I have the following class

class CodeRequest(@JsonProperty("phone") val phoneNumber: String)

When I send request (using retrofit) with an object of this class as body (while minification is not enabled) everything works and request will be send in this form {"phone": "123"}

But enabling minification with the following proguard-rules.pro will result in a {"phoneNumber": "123"} request body.

# Jackson
-keep class com.fasterxml.jackson.databind.ObjectMapper {
    public <methods>;
    protected <methods>;
}
-keep class com.fasterxml.jackson.databind.ObjectWriter {
    public ** writeValueAsString(**);
}
-keep @com.fasterxml.jackson.annotation.* class * { *; }
-keep @com.fasterxml.jackson.annotation.** class * { *; }
-keep class com.fasterxml.** { *; }
-keepattributes *Annotation*,EnclosingMethod,Signature,Exceptions,InnerClasses
-keep class * {
    @com.fasterxml.jackson.annotation.* *;
}
-keep class * { @com.fasterxml.jackson.annotation.JsonProperty *;}

# Application classes that will be serialized/deserialized over Jackson
-keepclassmembers class my.application.data.models.** { *; }
-keepclassmembers class my.application.domain.network.rest.** { *; }

What's missing here?

Thank you.

1 Answers
Related