无法调用no-args构造函数,gson

时间:2015-05-18 00:56:43

标签: java json gson

我收到此错误

Exception in thread "main" java.lang.RuntimeException: Unable to invoke no-args constructor for interface javax.xml.crypto.Data. Register an InstanceCreator with Gson for this type may fix this problem.

当我在这个类中运行代码时:

public class FinderClass {

    InputStream input;
    Reader reader;
    Data data;

    public FinderClass()
    {

    }

    public double findOtherWeapon(double weaponPrice) throws IOException
    {

        input = new URL("http://steamcommunity.com/market/search/render/?query=&start=0&count=10&search_descriptions=0&sort_column=quantity&sort_dir=desc&appid=730").openStream();
        reader = new InputStreamReader(input, "UTF-8");
        data = new Gson().fromJson(reader, Data.class);                 System.out.println("data");
        return -1;
    }

即使我有一个no-args构造函数,它仍然给我这个错误。我已经查找了如何使用InstanceCreator,但我真的不明白如何实现它。有人可以解释一下如何做到这一点吗?

0 个答案:

没有答案
相关问题