Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

继承了Model的类无法使用Gson转换为JSON #44

Closed
swjtuhyq opened this issue Dec 20, 2018 · 3 comments
Closed

继承了Model的类无法使用Gson转换为JSON #44

swjtuhyq opened this issue Dec 20, 2018 · 3 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@swjtuhyq
Copy link

No description provided.

@swjtuhyq swjtuhyq changed the title 继承了Model的类无法使用Gson 继承了Model的类无法使用Gson转换为JSON Dec 20, 2018
@swjtuhyq
Copy link
Author

swjtuhyq commented Dec 20, 2018

我的Model是这样的:

@Table(name = "test")
@Data
public class Test extends Model{
    private int id;
    private int flag;
}

转Json是这样的:

Test test = new Test();
test.setId(199);
test.setFlag(13);
String s = new Gson().toJson(test);

错误如下:

java.lang.UnsupportedOperationException: Attempted to serialize java.lang.Class: com.robelf.appstore.model.Test. Forgot to register a type adapter?

这是什么原因呢,需要怎么设置才能使用呢?

@hellokaton hellokaton self-assigned this Jan 5, 2019
@hellokaton hellokaton added question Further information is requested bug Something isn't working labels Jan 5, 2019
@hellokaton
Copy link
Owner

这是继承导致的序列化问题,已经修复了,在 0.2.6 版本中正常。

@swjtuhyq
Copy link
Author

swjtuhyq commented Jan 5, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants