title: How to parse this Betting API?
body: <p>i'm not very experienced in getting Jason responses in Android. My question is how to parse JSON coming from this API <code>https://api.the-odds-api.com/v2/odds/?sport=UPCOMING&amp;region=uk&amp;apiKey=e3b70c1881a5d9eec34e4cb256844874</code>. Basically for introduction, i need participants of events.Then I want to create a list of matches and create  <code>RecyclerView</code> from it. </p>
  
  <p>This is my class for communicating with API</p>
  
  <pre><code>private class JsonTask extends AsyncTask&lt;String, String, String&gt; implements OnVisibleCallback{
  
  
      protected String doInBackground(String... params) {
  
  
          HttpURLConnection connection = null;
          BufferedReader reader = null;
  
          try {
              URL url = new URL(params[0]);
              connection = (HttpURLConnection) url.openConnection();
              connection.connect();
  
  
              InputStream stream = connection.getInputStream();
  
              reader = new BufferedReader(new InputStreamReader(stream));
  
              StringBuffer buffer = new StringBuffer();
              String line = "";
  
              while ((line = reader.readLine()) != null) {
                  buffer.append(line+"\n");
                  Log.d("Response: ", "&gt; " + line);   //here u ll get whole response...... :-)
  
              }
  
              return buffer.toString();
  
  
          } catch (MalformedURLException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          } finally {
              if (connection != null) {
                  connection.disconnect();
              }
              try {
                  if (reader != null) {
                      reader.close();
                  }
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return null;
      }
  
      @Override
      protected void onPostExecute(String response) {
          super.onPostExecute(response);
          Log.d("json",response);
          try {
              JSONObject jObject = new JSONObject(response);
              String data = jObject.getString("data");
              JSONObject objData = new JSONObject(data);
              String events = objData.getString("events");
              JSONObject eventObj = new JSONObject(events);
              int numberOfEvents = eventObj.length();
  
  
  
  
  
              List&lt;Match&gt; matchList= Arrays.asList(new Match("Juventus","Fiorentina"));
  
  
              counter = 1;
              Log.d("Counter_Ticket_Fragment", String.valueOf(counter));
  
              mAdapter = new MatchAdapter(matchList,counter);
              changeVisible();
              mAdapter.setCallback(this);
              recyclerView.setAdapter(mAdapter);
              recyclerView.setItemAnimator(new DefaultItemAnimator());
  
          } catch (JSONException e) {
              e.printStackTrace();
          }
      }
  
      @Override
      public void changeVisible() {
          if(mAdapter.getItemCount()&gt;0){
              noMatch.setVisibility(View.GONE);
          }
          else{
              noMatch.setVisibility(View.VISIBLE);
          }
      }
  }
  </code></pre>
  
  <p>Somehow I got to the events but don't know how to proceed with this. I need a number of events because I want to create as many objects of Match.class(String homeTeam, String awayTeam) and pass it to the recycled view. I am doing this on this JsonTask and I think that's really not the best approach.<code>JsonTask</code> is being called in  <code>OnCreateView</code> of  <code>Fragment</code>.</p>
  
  <p>This is Match.class</p>
  
  <pre><code>   public class Match  {
  
  private String team_home;
  private String team_away;
  
  
  
          public Match(String team_home, String team_away){
              this.team_home = team_home;
              this.team_away = team_away;
          }
  
  public String getHomeTeam() {
      return team_home;
  }
  
  public String getAwayTeam() {
      return team_away;
  }
  }
  </code></pre>
  
  <p>And this is MatchAdapter</p>
  
  <pre><code>   public class MatchAdapter extends RecyclerView.Adapter&lt;MatchAdapter.MyViewHolder&gt; {
  private List&lt;Match&gt; matchList;
  private Context context;
  private int counter;
  private static SharedPreferences prefs;
  private OnVisibleCallback callback;
  
  
  public class MyViewHolder extends RecyclerView.ViewHolder {
      public TextView team_home, team_away;
      public View v;
  
  
      public MyViewHolder(View v) {
          super(v);
          this.v = v;
          team_home = (TextView) v.findViewById(R.id.team_home);
          team_away = (TextView) v.findViewById(R.id.team_away);
          context = v.getContext();
  
      }
  }
  
  
  public MatchAdapter(List&lt;Match&gt;  matchList, int counter) {
      this.matchList = matchList;
      this.counter = counter;
  }
  
  public void setCallback(OnVisibleCallback callback) {
      this.callback = callback;
  }
  
  @Override
  public MatchAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View itemView = LayoutInflater.from(parent.getContext())
              .inflate(R.layout.recycler_view_matches_row, parent, false);
      return new MyViewHolder(itemView);
  }
  
  
  @Override
  public void onBindViewHolder(final MatchAdapter.MyViewHolder holder, final int position) {
      final Match match = matchList.get(position);
      holder.team_home.setText(match.getHomeTeam());
      holder.team_away.setText(match.getAwayTeam());
  
  
  
  }
  
  @Override
  public int getItemCount() {
      return matchList.size();
  }
  
  }
  </code></pre>