本文整理汇总了Java中com.owlike.genson.GenericType类的典型用法代码示例。如果您正苦于以下问题:Java GenericType类的具体用法?Java GenericType怎么用?Java GenericType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GenericType类属于com.owlike.genson包,在下文中一共展示了GenericType类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doInBackground
import com.owlike.genson.GenericType; //导入依赖的package包/类
@Override
protected DataAdapter doInBackground(Void... params)
{
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet( "http://" + HOST + ":8080/fhws/api/persons" );
get.addHeader("Accept", "application/json" );
DataAdapter adapter = new DataAdapter(ShowPersons.this);
try
{
Genson genson = new Genson();
HttpResponse response = client.execute(get);
String reply = IOUtils.toString(response.getEntity().getContent());
Collection<Person> cp = genson.deserialize(reply, new GenericType<List<Person>>(){} );
for( Person p : cp )
{
adapter.addData(p);
}
}
catch( Exception e )
{
e.printStackTrace();
}
return adapter;
}
示例2: deserialize
import com.owlike.genson.GenericType; //导入依赖的package包/类
@Override
public Object deserialize(ObjectReader reader, Context ctx) throws IOException {
return ctx.genson.deserialize(GenericType.of(property.getType()), reader, ctx);
}
示例3: deserialize
import com.owlike.genson.GenericType; //导入依赖的package包/类
public static <T> T deserialize(String serialized, GenericType<T> c){
return getGenson().deserialize(serialized, c);
}