我正在尝试将 rest-facebook 响应转换为 Post 类对象,如下所示:
Post post = gson.fromJson(restFBResponse.toString(), Post.class);
其中,restFBResponse
是来自 Facebook 的帖子。但这会导致错误:
Exception in thread "main" java.lang.IllegalArgumentException: class com.restfb.types.Post declares multiple JSON fields named type
我认为这是由于:
1)
class Post extends NamedFacebookType{
@Facebook
private String type;
//and some more class members
}
2)
class NamedFacebookType extends FacebookType {
//few class members
}
3)
class FacebookType implements Serializable {
@Facebook
private String type;
//and some more class members
}
因此,在和private String type;
中被声明了两次。class Post
class FacebookType
1)如果子类中发生这样的重新声明,不应该被覆盖吗?和
2)我怎样才能克服这个错误class com.restfb.types.Post declares multiple JSON fields named type
?