title: Parsing JSON using Retrofit
body: <p>I have to parse the following JSON using Retrofit and display.</p>
  
  <p><a href="https://api.flickr.com/services/rest/?method=flickr.photos.getRecent&amp;api_key=6f102c62f41998d151e5a1b48713cf13&amp;format=json&amp;nojsoncallback=1&amp;extras=url_s" rel="nofollow noreferrer">https://api.flickr.com/services/rest/?method=flickr.photos.getRecent&amp;api_key=6f102c62f41998d151e5a1b48713cf13&amp;format=json&amp;nojsoncallback=1&amp;extras=url_s</a></p>
  
  <p>When I tried to run my app I got the following error: </p>
  
  <blockquote>
    <p>Expected <code>BEGIN_ARRAY</code> but was <code>BEGIN_OBJECT</code> at line 1 column 2 path $</p>
  </blockquote>
  
  <p>My code is below</p>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>package com.example.siva.gallery;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  import android.widget.Toast;
  
  import java.util.List;
  
  import retrofit2.Call;
  import retrofit2.Callback;
  import retrofit2.Response;
  import retrofit2.Retrofit;
  import retrofit2.converter.gson.GsonConverterFactory;
  
  public class MainActivity extends AppCompatActivity {
  
  ListView listView;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      listView = (ListView) findViewById(R.id.listview);
  
      //calling the method to display the heroes
      getPhoto();
  }
  
  private void getPhoto() {
      Retrofit retrofit = new Retrofit.Builder()
              .baseUrl(Api.BASE_URL)
              .addConverterFactory(GsonConverterFactory.create()) //Here we are using the GsonConverterFactory to directly convert json data to object
              .build();
  
      Api api = retrofit.create(Api.class);
  
      Call&lt;List&lt;Photo&gt;&gt; call = api.getPhoto("flickr.photos.getRecent","6f102c62f41998d151e5a1b48713cf13","json","1","url_s");
  
      call.enqueue(new Callback&lt;List&lt;Photo&gt;&gt;() {
          @Override
          public void onResponse(Call&lt;List&lt;Photo&gt;&gt; call, Response&lt;List&lt;Photo&gt;&gt; response) {
              List&lt;Photo&gt; photoList = response.body();
  
              //Creating an String array for the ListView
              String[] photos = new String[photoList.size()];
  
              //looping through all the heroes and inserting the names inside the string array
              for (int i = 0; i &lt; photoList.size(); i++) {
                  photos[i] = photoList.get(i).getTitle();
              }
  
  
              //displaying the string array into listview
              listView.setAdapter(new ArrayAdapter&lt;String&gt;(getApplicationContext(), android.R.layout.simple_list_item_1, photos));
  
          }
  
          @Override
          public void onFailure(Call&lt;List&lt;Photo&gt;&gt; call, Throwable t) {
              Toast.makeText(getApplicationContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
          }
      });
  }
  
  }
  </code></pre>
  
  <p><strong>Photo.java</strong></p>
  
  <pre><code>package com.example.siva.gallery;
  import com.google.gson.annotations.Expose;
  import com.google.gson.annotations.SerializedName;
  import com.google.gson.annotations.Expose;
  import com.google.gson.annotations.SerializedName;
  
  public class Photo {
  
  @SerializedName("id")
  @Expose
  private String id;
  
  @SerializedName("title")
  @Expose
  private String title;
  
  @SerializedName("url_s")
  @Expose
  private String urlS;
  
  public Photo(String mId, String mTitle, String mUrls ){
      id = mId;
      title = mTitle;
      urlS = mUrls;
  }
  
  public String getId() {
      return id;
  }
  
   public String getTitle() {
      return title;
  }
  public String getUrlS() {
      return urlS;
  }
  
  }
  </code></pre>
  
  <p><strong>Api.interface</strong></p>
  
  <pre><code>package com.example.siva.gallery;
  
  import java.util.List;
  
  import retrofit2.Call;
  import retrofit2.http.GET;
  import retrofit2.http.Query;
  
  public interface Api {
      String BASE_URL = "https://api.flickr.com/";
  
      @GET("services/rest/")
      Call&lt;List&lt;Photo&gt;&gt; getPhoto(@Query("method")String method, @Query("api_key") String api_key, @Query("format") String format, @Query("nojsoncallback") String nojsoncallback, @Query("extras") String extras);
      }
  </code></pre>
  
  <p>I could not find what the problem is.</p>