title: Parsing nested JSON Object in recyclerview using retrofit gives error: "Expected begin ARRAY but was BEGIN_OBJECT at line 1
body: <blockquote>
  <p>So i was trying to parse JSON data into my recyclerview. But got error
  saying: &quot;Expected begin ARRAY but was BEGIN_OBJECT at line 1&quot;</p>
  </blockquote>
  <p>My <strong>JSON</strong> response:</p>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;status&quot;: &quot;success&quot;,
      &quot;data&quot;: {
          &quot;0&quot;: {
              &quot;id&quot;: &quot;8&quot;,
              &quot;name&quot;: &quot;hmhshwv&quot;,
              &quot;description&quot;: &quot;vhhh&quot;,
              &quot;location&quot;: &quot;nhhjj&quot;
          },
          &quot;1&quot;: {
              &quot;id&quot;: &quot;54&quot;,
              &quot;name&quot;: &quot;mabwb&quot;,
              &quot;description&quot;: &quot;ywg&quot;,
              &quot;location&quot;: &quot;gwgw&quot;
          }
          &quot;2&quot;: {
              &quot;id&quot;: &quot;48&quot;,
              &quot;name&quot;: &quot;nnf&quot;,
              &quot;description&quot;: &quot;gwb&quot;,
              &quot;location&quot;: &quot;wggw&quot;
          }
      }
  }
  </code></pre>
  <p>My Model class:</p>
  <pre class="lang-java prettyprint-override"><code>public class DataModel {
  
      private String id;
      private String firstname;
      private String lastname;
      private String contact;
  
  
      public DataModel(String id, String firstname, String lastname, String contact) {
          this.id = id;
          this.firstname = firstname;
          this.lastname = lastname;
          this.contact = contact;
      }
  
      public String getId() {
          return id;
      }
  
      public void setId(String id) {
          this.id = id;
      }
  
      public String getFirstname() {
          return firstname;
      }
  
      public void setFirstname(String firstname) {
          this.firstname = firstname;
      }
  
      public String getLastname() {
          return lastname;
      }
  
      public void setLastname(String lastname) {
          this.lastname = lastname;
      }
  
      public String getContact() {
          return contact;
      }
  
      public void setContact(String contact) {
          this.contact = contact;
      }
  }
  </code></pre>
  <p>My apiInterface:
  the api has body parameters such as apikey, userid and storeid.</p>
  <pre class="lang-java prettyprint-override"><code>public interface MyApiCall {
  
      @Headers(&quot;Accept: application/json&quot;)
      @POST(&quot;mybiz/api/staff-list&quot;)
      Call&lt;List&lt;DataModel&gt;&gt; getDataModel(
          @Body String apikey,
          @Body String userid,
          @Body String storeid
      );
  }
  </code></pre>
  <p>My <strong>RetrofitClient</strong> class:</p>
  <pre class="lang-java prettyprint-override"><code>public class RetrofitClient {
  
      private static final String BASE_URL = &quot;https://api.pidu.in/&quot;;
      private static Retrofit retrofit = null;
      public static MyApiCall getRetrofitClient() {
          if(retrofit == null) {
              retrofit = new Retrofit.Builder()
                      .baseUrl(BASE_URL)
                      .addConverterFactory(GsonConverterFactory.create())
                      .build();
          }
          return retrofit.create(MyApiCall.class);
      }
  }
  </code></pre>
  <p>My <strong>MainActivity</strong>:</p>
  <pre class="lang-java prettyprint-override"><code>private static final String TAG = MainActivity.class.getSimpleName();
  private static final String apikey = &quot;somethinggg&quot;;
  private static final String userid = &quot;a number&quot;;
  private static final String storeid = &quot;158&quot;;
  
  RecyclerView recyclerView;
  ProgressBar progressBar;
  LinearLayoutManager linearLayoutManager;
  DataModelAdapter dataModelAdapter;
  List&lt;DataModel&gt; dataModels = new ArrayList&lt;&gt;();
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
      progressBar = (ProgressBar) findViewById(R.id.progressBar3);
      linearLayoutManager = new LinearLayoutManager(this);
      recyclerView.setLayoutManager(linearLayoutManager);
      dataModelAdapter = new DataModelAdapter(dataModels);
      recyclerView.setAdapter(dataModelAdapter);
  
      fetchDataModel();
  
  }
  
  private void fetchDataModel() {
  
      progressBar.setVisibility(View.VISIBLE);
      RetrofitClient.getRetrofitClient().getDataModel(apikey, userid, storeid).enqueue(new Callback&lt;List&lt;DataModel&gt;&gt;() {
  
          @Override
          public void onResponse(@NonNull Call&lt;List&lt;DataModel&gt;&gt; call, @NonNull Response&lt;List&lt;DataModel&gt;&gt; response) {
              if(response.isSuccessful() &amp;&amp; response.body() != null) {
  
                  Log.e(TAG, &quot;Error: &quot; + response.body());
                  dataModels.addAll(response.body());
                  dataModelAdapter.notifyDataSetChanged();
                  progressBar.setVisibility(View.GONE);
  
              }
          }
  
          @Override
          public void onFailure(@NonNull Call&lt;List&lt;DataModel&gt;&gt; call, @NonNull Throwable t) {
              Toast.makeText(MainActivity.this, &quot;Error: &quot; + t.getLocalizedMessage(), Toast.LENGTH_LONG).show();
          }
      });
  }
  </code></pre>
  <p>And for reference my hoppscotch api looks like:</p>
  <p><a href="https://i.stack.imgur.com/gQKyU.png" rel="nofollow noreferrer">hoppscotch api</a></p>
  <p>I understand that I should parse the JSON object but can't find a particular way to do that.</p>