title: Using Retrofit2 along with recyclerview for nested JSON, response incompatibility
body: <p>So, I have been trying to parse and display a nested JSON into recycler view using retrofit2.</p>
  
  <p>The problem that I am facing is that the response is not compatible with the object.
  The following code and the representation will help the reader understand better.</p>
  
  <pre><code>public class FragmentTransaction extends Fragment {
  
  Transactions transactions;
  RecyclerView recyclerView;
  TransactionsAdapter transactionsAdapter;
  private View view;
  
  @Override
  public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle savedInstanceState){
      recyclerView = (RecyclerView)view.findViewById(R.id.recyclerView);
  
      LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
      recyclerView.setLayoutManager(layoutManager);
      transactionsAdapter = new TransactionsAdapter(getContext(), transactions);   //first occurrence of error
      recyclerView.setAdapter(transactionsAdapter);
      APIInterface apiInterface = APIClient.getClient().create(APIInterface.class);
      Call&lt;Transactions&gt; call = apiInterface.getTransactionList(sharedPreferences.getString(UNIQUE_ID, "qwe"));
      call.enqueue(new Callback&lt;Transactions&gt;() {
          @Override
          public void onResponse(Call&lt;Transactions&gt; call, Response&lt;Transactions&gt; response) {
  
              transactions = response.body();
              Log.d("5", "Passing to Adapter");
              try {
                  transactionsAdapter.setTransactionsList(transactions);   //second occurrence of error
  
                  Log.d("4", "Passed to Adapter");
              }
              catch (Exception e)
              {
                  e.printStackTrace();
              }
          }
  
          @Override
          public void onFailure(Call&lt;Transactions&gt; call, Throwable t) {
              Log.d("6", "Passing to Adapter Failure", t);
          }
      });
  </code></pre>
  
  <p>in both the cases the error is </p>
  
  <blockquote>
    <p>'TransactionsAdapter(android.content.Context, java.util.List)' in 'in.sid.POJO.TransactionsAdapter' cannot be applied to '(android.content.Context, in.sid.POJO.Transactions)'</p>
  </blockquote>
  
  <p>A visual representation </p>
  
  <p><a href="https://i.stack.imgur.com/1IxEu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1IxEu.png" alt="enter image description here"></a></p>
  
  <p>Also, I tried to change the recyclerviewadapter to work without List&lt;>, but I couldn't make it work and I cannot change the API call because when I did that, it gives me the following error</p>
  
  <blockquote>
    <p>Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $</p>
  </blockquote>
  
  <p>Lastly, I would be happy to provide more information but for now I am Keeping this small.</p>
  
  <p><strong>Update 1</strong></p>
  
  <p><strong>Adapter Class</strong></p>
  
  <pre><code>public class TransactionsAdapter extends RecyclerView.Adapter&lt;TransactionsAdapter.MyViewHolder&gt;{
  private Context context;
  private List &lt;Transactions&gt; TransactionsList;
  
  
  public TransactionsAdapter(Context context, List&lt;Transactions&gt; TransactionsList) {
      this.context = context;
      this.TransactionsList = TransactionsList;
  }
  
  public void setTransactionsList(List&lt;Transactions&gt; transactionsList){
      this.TransactionsList = transactionsList;
  
      notifyDataSetChanged();
  }
  
  @Override
  public TransactionsAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      return new MyViewHolder(view);
  }
  
  @Override
  public void onBindViewHolder(TransactionsAdapter.MyViewHolder holder, int position) {
      Transactions transactionsList = TransactionsList.get(position);
      Transactions.DataEntity dataEntity = transactionsList.getData().get(0);
      holder.associateName.setText(dataEntity.getAssociate().getName());
     }
  
  @Override
  public int getItemCount() {
      return 0;
  }
  
  public class MyViewHolder extends RecyclerView.ViewHolder{
  
      TextView associateName;
      TextView transactionDate;
  
      public MyViewHolder(View itemView) {
          super(itemView);
          associateName = (TextView)itemView.findViewById(R.id.nameAssociate);
          transactionDate = (TextView)itemView.findViewById(R.id.dateTransaction);
  }
  }
  }
  </code></pre>
  
  <p><strong>Response</strong> </p>
  
  <pre><code>{
  "status": "success",
  "status_code": "200",
  "data": [
      {
          "transaction_id": "2",
          "transaction_date": "2018-04-19 05:27:23.0",
          "amount": "200.00",
          "user_id": "2",
          "currency": "MXN",
          "associate_id": "1",
          "associate": {
              "is_active": "N",
              "associate_type": "Autoservicio",
              "name": "alsuper",
              "created_date": "12-Feb-2018 07:31:58 AM",
              "associate_id": "1",
              "url": null,
              "last_update_date": "12-Feb-2018 07:31:58 AM"
          },
          "card_id": "2",
          "card": {
              "bank_code": "002",
              "is_active": "Y",
              "allows_charges": "Y",
              "card_number": "411111XXXXXX1111",
              "openpay_card_id": "kiusphu8moqri6qys7sg",
              "type": "debit",
              "card_id": "2",
              "expiration_year": "21",
              "user_id": "2",
              "expiration_month": "10",
              "bank_name": "bank name",
              "created_date": "21-Mar-2018 05:46:58 AM",
              "brand": "visa",
              "last_update_date": "21-Mar-2018 05:46:58 AM",
              "holder_name": "name name name name"
          }
      }
  ]
  }
  </code></pre>
  
  <p><strong>POJO Class</strong></p>
  
  <pre><code>public class Transactions {
  
  @SerializedName("data")
  private List&lt;DataEntity&gt; data;
  @SerializedName("status_code")
  private String statusCode;
  @SerializedName("status")
  private String status;
  
  public List&lt;DataEntity&gt; getData() {
      return data;
  }
  
  public void setData(List&lt;DataEntity&gt; data) {
      this.data = data;
  }
  
  public String getStatusCode() {
      return statusCode;
  }
  
  public void setStatusCode(String statusCode) {
      this.statusCode = statusCode;
  }
  
  public String getStatus() {
      return status;
  }
  
  public void setStatus(String status) {
      this.status = status;
  }
  
  public static class DataEntity {
      @SerializedName("card")
      private CardEntity card;
      @SerializedName("card_id")
      private String cardId;
      @SerializedName("associate")
      private AssociateEntity associate;
      @SerializedName("associate_id")
      private String associateId;
      @SerializedName("currency")
      private String currency;
      @SerializedName("user_id")
      private String userId;
      @SerializedName("amount")
      private String amount;
      @SerializedName("transaction_date")
      private String transactionDate;
      @SerializedName("transaction_id")
      private String transactionId;
  }
  
  public static class CardEntity {
      @SerializedName("holder_name")
      private String holderName;
      @SerializedName("last_update_date")
      private String lastUpdateDate;
      @SerializedName("brand")
      private String brand;
      @SerializedName("created_date")
      private String createdDate;
      @SerializedName("bank_name")
      private String bankName;
      @SerializedName("expiration_month")
      private String expirationMonth;
      @SerializedName("user_id")
      private String userId;
      @SerializedName("expiration_year")
      private String expirationYear;
      @SerializedName("card_id")
      private String cardId;
      @SerializedName("type")
      private String type;
      @SerializedName("openpay_card_id")
      private String openpayCardId;
      @SerializedName("card_number")
      private String cardNumber;
      @SerializedName("allows_charges")
      private String allowsCharges;
      @SerializedName("is_active")
      private String isActive;
      @SerializedName("bank_code")
      private String bankCode;
  }
  
  public static class AssociateEntity {
      @SerializedName("last_update_date")
      private String lastUpdateDate;
      @SerializedName("associate_id")
      private String associateId;
      @SerializedName("created_date")
      private String createdDate;
      @SerializedName("name")
      private String name;
      @SerializedName("associate_type")
      private String associateType;
      @SerializedName("is_active")
      private String isActive;
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  }
  </code></pre>