【发布时间】:2015-08-04 03:15:54
【问题描述】:
在 Gson 文档中,我遇到了这个构造,用于将 JSON 化的 Spotify Artist 对象列表转换回对象的 ArrayList。我在 onRestoreInstanceState() 中使用它。
但是,我从未见过声明后的 {}。有人可以向我解释这是什么意思吗?我知道 getType() 是一个成员类,但为什么是 {}?
Type type = new TypeToken<List<Artist>>() {}.getType();
mArtistsList = new Gson().fromJson(jsonSearchResults, type);
【问题讨论】: