title: Android add json array to Pojo class
body: <p>I have following <code>JSON</code> returned from server</p>
  
  <pre><code>{
    "matches": [
      {
        "unique_id": 1122278,
        "date": "2018-01-24T00:00:00.000Z",
        "team-2": "India",
        "team-1": "South Africa",
        "type": "Test",
        "dateTimeGMT": "2018-01-24T08:00:00.000Z",
        "squad": true,
        "toss_winner_team": "India",
        "matchStarted": true
      },
      {
        "unique_id": 1116929,
        "team-2": "India Under-19s",
        "team-1": "Bangladesh Under-19s",
        "type": "YouthODI",
        "date": "2018-01-25T00:00:00.000Z",
        "dateTimeGMT": "2018-01-25T21:30:00.000Z",
        "squad": true,
        "toss_winner_team": "India Under-19s",
        "winner_team": "India Under-19s",
        "matchStarted": true
      },
  
      {
        "unique_id": 1115781,
        "team-2": "England",
        "team-1": "New Zealand",
        "type": "Test",
        "date": "2018-03-29T00:00:00.000Z",
        "dateTimeGMT": "2018-03-29T22:00:00.000Z",
        "squad": false,
        "matchStarted": false
      }
    ],
    "v": "1",
    "ttl": 43,
    "provider": {
      "source": "Various",
      "url": "https://cricapi.com/",
      "pubDate": "2018-01-27T13:18:55.717Z"
    },
    "creditsLeft": 250
  }
  </code></pre>
  
  <p>Using <code>Volley library</code> and  <code>gson</code>. </p>
  
  <p>I am trying to push <code>JSON array</code> <code>match</code> to <code>Match Model(Pojo)</code>. I think I can insert it using a loop, but there any other way to add all <code>JSON</code> array to model?</p>
  
  <pre><code>public class Main2Activity extends AppCompatActivity {
  
      RecyclerView recyclerView;
      ArrayList&lt;Match&gt; matches;
      MyAdapter myAdapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.recylcer_1);
  
         recyclerView=(RecyclerView) findViewById(R.id.recyler);
          myAdapter=new MyAdapter(matches);
          RecyclerView.LayoutManager layoutManager=new LinearLayoutManager(getApplicationContext());
          recyclerView.setLayoutManager(layoutManager);
          recyclerView.setAnimation(n);
          recyclerView.setAdapter(myAdapter);
          callCricket();
      }
  
      public void callCricket() {
  
          CallApi callApi = new CallApi();
          callApi.setVolleyInterface(new VolleyInterface() {
              @Override
              public void onSucess(String string) {
                  Log.d("ApiCall_success", string);
  
                  Gson gson = new Gson();
                  Type type = new TypeToken&lt;ArrayList&lt;Match&gt;&gt;(){}.getType();
                  JSONObject jsonObject = null;
                  try {
  
                      jsonObject = new JSONObject(string);
                      JSONArray jsonArray = jsonObject.getJSONArray("matches");
                      matches.addAll(gson.fromJson(jsonArray,type));
                  } catch (JSONException e) {
                      e.printStackTrace();
                  }
              }
  
              @Override
              public void onError(String string) {
  
              }
          }); 
      }
  }
  </code></pre>
  
  <p>I have tried using <code>gson</code> but I got an error.</p>