Gson Exception: No-args constructor for class XXX does not exit.
来源:互联网 发布:华为大数据产业园 编辑:程序博客网 时间:2024/05/14 22:03
Gson Exception: No-args constructor for class XXX does not exit.
Use JDO and RESTful web services at GAE. Usually need to parser JSON format string by Gson. But, some JDO class doesn't have No-args constructor, public YourClass(){}, and therefore the gson instance will throw out exception, No-args constructor for class XXX does not exit.
There are two ways to fix this problem:
One, add No-args constructor in the JDO class.
The other is use InstanceCreator to instead a no-argument constructor.
Example:
There are two ways to fix this problem:
One, add No-args constructor in the JDO class.
The other is use InstanceCreator to instead a no-argument constructor.
Example:
public class YourClassInstanceCreator implements InstanceCreator<YourClass> {
public YourClass createInstance(Type type) {
return new YourClass(null, null, null, null);
}
}
GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(YourClass.class, new YourClassInstanceCreator());
Gson gson = builder.create();
stoken = gson.fromJson(json, YourClass.class);
- Gson Exception: No-args constructor for class XXX does not exit.
- Gson : Unable to invoke no-args constructor for class
- Args in class constructor
- The source attachment does not contain the source for the file xxx class
- Java-出现The source attachment does not contain the source for the file xxx class
- C# does not contain a constructor that takes no parameter
- Hibernate报错:No default constructor for entity xxx
- the source attachment does not contain the source for the file xxx.class无法关联到某个类
- the source attachment does not contain the source for the file xxx.class无法关联到某个类
- Error: Activity class {XXX} does not exist的问题解决
- Could not instantiate bean class [java.util.Date]: Constructor threw exception; nested exception is
- Google App Engine错误解决方案之Class com.xxx.xxx does not seem to have been enhanced. You may want to rerun the enhancer and check for
- Cannot construct net.sourceforge.cruisecontrol.BuildLoopInformation as it does not have a no-args co
- ORA-01720: grant option does not exist for 'xxx.xxxx'
- Parameter Maps collection does not contain value for XXX.map
- ORA-01720: grant option does not exist for 'xxx.xxxx'
- MyBatis:Mapped Statements collection does not contain value for xxx
- File xxx specified for property 'resourceFile' does not exist.解决方法
- Android中退出多个Activity的方法
- sqlite3的一些常用语句
- SDN文献阅读
- 使用JLink间接烧写S3C2410、S3C2440开发板Nor、Nand Flash的方法
- color transfer between images
- Gson Exception: No-args constructor for class XXX does not exit.
- 如何Shrink Undo表空间,释放过度占用的空间
- SSH将Excel中的数据读入保存到数据库中
- 颜色恒常性 & Retinex
- 慧荣SMI_量产图文教程
- 求人不如求己
- iceiceice-Hadoop应用之旅一
- 编程趣味题1
- 强悍的VIM,强悍的配置文件!!!