N
N
newdancer2016-12-16 16:40:23
Android
newdancer, 2016-12-16 16:40:23

How to parse json through retrofit2 with an array type structure?

How to parse json via retrofit with an array type structure? If the size is unknown

[
{"title_ru":"Двойной форсаж","kinopoisk_id":"323"},
{"title_ru":"Экс-любовник","kinopoisk_id":"171822"}
]

The problem is how to find out the size of the received data
I made a model for retrofit2
public class ModelSearch {

  @SerializedName("title_ru")
  private String title_ru;
  @SerializedName("kinopoisk_id")
  private String kinopoisk_id;

  public String getTitle() {
    return title_ru;
  }

  public void setTitle(String title_ru) {
    this.title_ru = title_ru;
  }

  public String getKP() {
    return kinopoisk_id;
  }

  public void setKP(String kinopoisk_id) {
    this.kinopoisk_id = kinopoisk_id;
  }

}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri, 2016-12-17
@YuryBorodkin

Try List < ModelSearch >.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question