本文整理匯總了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);
}