The error im getting is "java.lang.IllegalArgumentException: class com.activeandroid.DatabaseHelper declares multiple JSON fields named mContext"
I am using AndroidAnnotations RestClient to pull data from my Web Service and serialize into POJOs. The serializations worked fine while using ORMLite but i recently decided to try out Active Android and now my classes extends Model. Gson is serializing the parent class which i have no control over. Any way I can only include certain fields or maybe just return plain JSON from the RestClient and do the serialization a different way
@Rest(rootUrl = "http://stuff...com", converters = { GsonHttpMessageConverter.class })
public interface RestClient {
@Get("/AndroidController/createFacebookUser?facebookToken={facebookToken}&catIds= {catIds}")
User createFacebookUser(String facebookToken,String catIds);
}
and the User model is
@Data
@Table(name = "Users")
public class User extends Model {
@Column(name = "SystemID")
private String systemID;
@Column(name = "Name")
private String name;
public List<GameEntry> items() {
return getMany(GameEntry.class, "Category");
}
public User(){}
}
Gson provides multiple ways of excluding fields and types from Serialization and Deserialization. Take a look at Excluding Fields From Serialization and Deserialization, specifically the usage of @Expose
annotation and user-defined ExclusionStrategy
.
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