-2

我有

SearchResponse response = gson.fromJson(reader,SearchResponse.class); List<Result> results = response.results;

但是,我需要提供一个使用 classLoader 创建的类

File path = new File (classFilesPath + File.separator + getFileNameName() );
ClassLoader LOADER = ClassLoader.getSystemClassLoader();
URLClassLoader loader = new URLClassLoader(new URL[] { path.toURI().toURL() }, LOADER);
Class loadedClass = loader.loadClass(fullyQualifiedClassName);

如何在 gson.fromJson 中使用 loadedClass ?

4

1 回答 1

0

如何在 gson.fromJson 中使用 loadedClass ?

Object thing = new Gson().fromJson(jsonInput, loadedClass);
于 2012-07-13T17:37:33.947 回答