次のような Band を表す JSON 応答があります。
[
{
"Picture": {
"Small": "someurl
"Medium": "someurl",
"Large": "someurl",
"XLarge": "someurl"
},
"Name": "Tokyo Control Tower",
"Guid": "TCT",
"ID": 15
}
]
そして、GSON を使用して、バンドのリストを含む SearchResults というクラスに逆シリアル化しようとしています。私の SearchResults と Band クラスは次のようになります。
public class SearchResults {
public List<Band> results;
}
public class Band {
@SerializedName("Name")
public String name;
@SerializedName("Guid")
public String guid;
@SerializedName("ID")
public Integer id;
@SerializedName("Picture")
List<Photo> pictures;
}
私のコードでは、json 文字列を次のように変換しようとしています。
protected void onPostExecute(String result) {
Gson gson = new Gson();
SearchResults results = gson.fromJson(result, SearchResults.class);
Band band = results.results.get(0);
bandName.setText(band.name);
}
このコードを実行すると、GSON から、Expected BEGIN_OBJECT but was BEGIN_ARRAY というエラーが表示されます。修正方法に関するアイデアはありますか?