title: How to fetch JSONArray using retrofit2 and RXJava2
body: <p>I am using Retrofit2 and RxJava2 for fetching data from the server.I have response in below format:</p>
  
  <pre><code> {
     "product_data": [
      {
          "product_name": "Pi-Pi jod kar ye Notebook li hai",
          "product_price": "249.00",
          "category_id": "9",
          "product_id": "125",
          "product_photo": "1574935198_1.jpg"
      },
      {
          "product_name": "Tere Jesa year kaha kaha esa yarana",
          "product_price": "249.00",
          "category_id": "9",
          "product_id": "128",
           "product_photo": "1574935455_1.jpg"
       }
      ]
     } 
  </code></pre>
  
  <p>I am getting exception below:</p>
  
  <pre><code>Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $.
  </code></pre>
  
  <p><strong>ApiService.class</strong></p>
  
  <pre><code>public interface ApiService {
  
  @GET("general_cat_api")
  Observable&lt;List&lt;HomeGeneralModel&gt;&gt; getData();
  
  }
  </code></pre>
  
  <p><strong>RetrofitClient.class</strong></p>
  
  <pre><code>public class RetrofitClient {
  
  private static Retrofit retrofit = null;
  
  public static Retrofit getInstance(){
  
  
      OkHttpClient okHttpClient = new OkHttpClient.Builder()
              .connectTimeout(22, TimeUnit.SECONDS)
              .readTimeout(22, TimeUnit.SECONDS)
              .writeTimeout(22, TimeUnit.SECONDS)
              .build();
  
      if(retrofit == null)
          retrofit = new Retrofit.Builder()
                  .baseUrl("http://aamku.com/api/")
                  .addConverterFactory(GsonConverterFactory.create(new GsonBuilder().setLenient().create()))
                  .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                  .client(okHttpClient)
                  .build();
  
      return retrofit;
  
  }
  
  private RetrofitClient(){
  
    }
  }
  </code></pre>
  
  <p>Now I am using retrofit some thing like below to fetch data:</p>
  
  <pre><code>private void getData(){
  
      Retrofit retrofit = RetrofitClient.getInstance();
      ApiService myApi = retrofit.create(ApiService.class);
  
      myApi.getData().subscribeOn(Schedulers.io())
                     .observeOn(AndroidSchedulers.mainThread())
                     .subscribe(new Observer&lt;List&lt;MenuModel&gt;&gt;() {
                         @Override
                         public void onSubscribe(Disposable d) {
  
                         }
  
                         @Override
                         public void onNext(List&lt;MenuModel&gt; menuModels) {
  
                             if(menuModels.size() &gt; 0){
  
                                 menuProg.setVisibility(View.INVISIBLE);
                                 list.addAll(menuModels);
  
                                 adapter = new MenuAdapter(list,MainActivity.this);
                                 menuRecycler.setAdapter(adapter);
                             }
                         }
  
                         @Override
                         public void onError(Throwable e) {
  
                             menuProg.setVisibility(View.INVISIBLE);
                             Toast.makeText(getApplicationContext(),e.getMessage(),Toast.LENGTH_SHORT).show();
                         }
  
                         @Override
                         public void onComplete() {
  
                         }
                     });
  }
  </code></pre>
  
  <p>Someone please let me know why I am getting this exception.Any help would be appreciated.</p>
  
  <p><strong>THANKS</strong></p>