There is the following structure:

@SerializedName("data") @Expose private List<Data> data = new ArrayList<Data>(); 

How to write parcel for her?

  @Override public void writeToParcel(Parcel parcel, int i) { //Что тут написать? } 

    2 answers 2

    parcel.writeTypedList(data);

    At the same time, the Data class should also be Parcelable.

    To read the list in the creator, you will need to write:

    data = parcel.createTypedArrayList(Data.CREATOR);

    Method descriptions:

    https://developer.android.com/reference/android/os/Parcel.html#writeTypedList(java.util.List%3CT%3E)

    https://developer.android.com/reference/android/os/Parcel.html#createTypedArrayList(android.os.Parcelable.Creator%3CT%3E)

    I recommend the Android Parcelable Code Generator plugin for Android Studio.

    PS Instead of sending a structure of the type {data: [...]} with the back-end, you can send [...] , and in Android you can take it as ArrayList<Data> .

      If Data implements Parcelable , then you can use the methods:
      - parcel.writeTypedList(data) for writing
      - parcel.createTypedArrayList(Data.CREATOR) for reading
      The documentation provides a complete list of possible methods.