私はJson文字列を持っています。私は2つのリスト(カテゴリと製品)でRetrofitでonResponseできませんでした。コールバック、コールバック私は何を使うべきですか?通常はリストではないでしょうか?通常でJsonオブジェクト複数の配列Parse、retrofit
{
"Categories": [{"name":"x products",
"products":[{}{}{}]}
{"name":"y products",
"products":[{}{}{}]}
{"name":"z products",
"products":[{}{}{}]} ],
"CoverPageURL":"xx.png",
"Location": "Canada",
"adress":"opposite of hospital"
"ProductItems": [
{"large":"xx"
"mall":"tt"}
{"large":"yy"
"mall":"gg"}]
"Status": {
"ErrorCode": 0,
"Error": null,
"HasError": false
}
私は
ブロック// What i should write here
で
Call<Merchant> call = ToolApi.getApi().GetMerchant(BaseService.TOKEN);
call.enqueue(new Callback<Merchant>() {
@Override
public void onResponse(Response<Merchant> response, Retrofit retrofit) {
if (response.body() == null) {
}else{
//I bought the bottoms from another class just For example
//normaly one list and its' items. but in that case i have two list on JSON
//start
HomePageContent homePageContent = response.body();
Integer errorCode = homePageContent.getStatus().getErrorCode();
if (errorCode == 0) {
/// What i should write here
List<ItemHomePagecontent> items = homePageContent.getItems();
HeadRecyclerListHomePageContent.setHasFixedSize(true);
homePageAdapter = new HomePageAdapter(homePageContent, items, context());
HeadRecyclerListHomePageContent.setLayoutManager(new LinearLayoutManager(context(), LinearLayoutManager.VERTICAL, false));
HeadRecyclerListHomePageContent.setAdapter(homePageAdapter);
//finish
}
@Override
public void onFailure(Throwable t) {
}
....
JSONをPOJOに解析する方法を知りたいですか? –
@AishwaryaTiwari私はquesitonを編集します。いいえ、POJOではありません。私はどのようにリストを置くのか知りたいですか?ありがとうございます – Jenni
JSONが無効です。 JSONが[JSONLint](http://jsonlint.com/)で有効かどうかを確認してください。有効なJSONを投稿すると、適切に対応できます。 –