title: JSON data is not fetching using Retrofit
body: <p>I am using retrofit networking library for fetching data from server.I am using MVVM architecture model to create an app.When app starts it is showing some exception and not fetching data.</p>
  
  <blockquote>
    <p>java.lang.IllegalStateException:Expected BEGIN_OBJECT but was BEGIN_ARRAY at Line 1 Column 2 path $.</p>
  </blockquote>
  
  <p>I am fail to understand what it is trying to say.Below is my code.</p>
  
  <p><strong>RetrofitClient.java</strong></p>
  
  <pre><code>public class RetrofitClient {
  
  private static Retrofit retrofit = null;
  private static final String URL = "https://example.com/";
  
  public static Retrofit getInstance(){
  
      OkHttpClient okHttpClient = new OkHttpClient.Builder()
                                .connectTimeout(20, TimeUnit.SECONDS)
                                .readTimeout(20,TimeUnit.SECONDS)
                                .writeTimeout(20,TimeUnit.SECONDS)
                                .build();
  
      if(retrofit == null){
  
          retrofit = new Retrofit.Builder()
                     .baseUrl(URL)
                     .addConverterFactory(GsonConverterFactory.create(new GsonBuilder().setLenient().create()))
                     .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                     .client(okHttpClient)
                     .build();
      }
  
      return retrofit;
    }
  
  private RetrofitClient(){
  
    }
  }
  </code></pre>
  
  <p><strong>ApiService.class</strong></p>
  
  <pre><code>public interface ApiService {
  
      @GET("getUsers")
      Call&lt;User&gt; getUser();
  }
  </code></pre>
  
  <p><strong>User.java</strong></p>
  
  <pre><code>public class User {
  
  @SerializedName("name")
  @Expose
  private String name;
  
  @SerializedName("age")
  @Expose
  private String age;
  
  public User(String name, String age) {
      this.name = name;
      this.age = age;
   }
  
  public String getName() {
      return name;
   }
  
  public void setName(String name) {
      this.name = name;
   }
  
  public String getAge() {
      return age;
   }
  
  public void setAge(String age) {
      this.age = age;
   }
  }
  </code></pre>
  
  <p><strong>UserRepository.java</strong></p>
  
  <pre><code>public class UserRepository {
  
  Context context;
  
  public UserRepository(Context context) {
      this.context = context;
  }
  
  public void getUserList(){
  
            Retrofit retrofit = RetrofitClient.getInstance();
            ApiService apiService = retrofit.create(ApiService.class);
  
            Call&lt;User&gt; userList = apiService.getUser();
  
            userList.enqueue(new Callback&lt;User&gt;() {
                @Override
                public void onResponse(Call&lt;User&gt; call, Response&lt;User&gt; response) {
  
               Log.d("Response", String.valueOf(response.body()));
         }
  
                @Override
                public void onFailure(Call&lt;User&gt; call, Throwable t) {
  
                    Toast.makeText(context,t.getMessage(),Toast.LENGTH_LONG).show();
                }
            });
    }
  }
  </code></pre>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  UserRepository userRepository;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Toolbar toolbar = findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  
      FloatingActionButton fab = findViewById(R.id.fab);
      fab.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Intent i = new Intent(MainActivity.this,AddUser.class);
              startActivity(i);
          }
      });
  
      userRepository = new UserRepository(this);
  
      userRepository.getUserList();
  }
  </code></pre>
  
  <p><strong>API Response</strong></p>
  
  <pre><code>[
    {
      "name": "Link",
      "age": "5"
    },
    {
      "name": "Rhea",
      "age": "24"
    },
    {
      "name": "Don",
      "age": "10"
    },
    {
      "name": "oman",
      "age": "30"
    },
    {
      "name": "Ron",
      "age": "18"
    },
    {
      "name": "roman",
      "age": "25"
    }
  ]
  </code></pre>
  
  <p>Someone please let me know why above exception is showing am I doing something wrong. Any help would be appreciated.</p>
  
  <p><strong>THANKS</strong> </p>