Is there a way to exclude primitive and Object properties within Serializable Object from GWT Serialization?
public class Provider implements Serializable{
public Provider() {
}
//Id like to exclude this property:
private String password;
//
private String address1;
private String address2;
private String companyName;
private String phone;
}
If there are fields in Java objects that do not wish to be serialized, we can use the @JsonIgnore annotation in the Jackson library. The @JsonIgnore can be used at the field level, for ignoring fields during the serialization and deserialization.
You could use the transient keyword to omit a field from being serialized. For example: int k; transient int j; Variable j will not be serialized as we have mentioned the transient keyword.
I was hoping for something like special annotation
I think what you are looking for is @GwtTransient
@GwtTransient
, an annotation that tells GWT RPC to treat a field as if it were marked with the Java transient keyword, even though it's not.This annotation means the same thing as the
transient
keyword, but it is ignored by all serialization systems other than GWT's. Usually thetransient
keyword should be used in preference to this annotation. However, for types used with multiple serialization systems, it can be useful.
Reference: @GwtTransient
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With