title: Retrofit Android : java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path
body: <p>Similar questions were asked before. But none of them worked for me.
  I am trying to return an observable, to which a subscriber is listening.
  Everytime the subscriber's onError() method is being called with <strong>"java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $"</strong> this error.</p>
  
  <p>Here is my code : </p>
  
  <pre><code>public Observable&lt;List&lt;String&gt;&gt; getPlaces() {
      Retrofit retrofit = new Retrofit.Builder()
          .addConverterFactory(GsonConverterFactory.create())
          .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
          .baseUrl(Urls.BASE_URL)
          .build();
      RetroFitInterface service = retrofit.create(RetroFitInterface.class);
      return service.getPlaces();
  }
  
  
  
  
  public interface RetroFitInterface {
  
      @Headers({
              "Accept: application/json",
              "Content-Type: application/json"
      })
      @GET(Urls.GET_POPULAR_LOCATIONS_URL)
      Observable&lt;List&lt;String&gt;&gt; getPlaces();
  }
  </code></pre>
  
  <p>HERE IS A JSON RESPONSE : </p>
  
  <pre><code>{
      "locations": [
          "location1",
          "location2",
          "location3",
          "location4",
          "location5",
          "location6",
          "location7",
      ],
      "success": true
  }
  </code></pre>
  
  <p>This is how I am subscribing the subscriber.</p>
  
  <pre><code>getPlaces().subscribeOn(Schedulers.io())
                  .subscribe(new Observer&lt;List&lt;String&gt;&gt;() {
                      @Override
                      public void onCompleted() {
                          Log.d(TAG, "Search result onCompleted()!");
                      }
  
                      @Override
                      public void onError(Throwable e) {
                          Log.d(TAG, "Search result onError()! " + e.toString());
                      }
  
                  @Override
                  public void onNext(final List&lt;String&gt; result) {
                      Log.d(TAG, "This is never called.");
                  }
              })
  </code></pre>