0
[
  [
    {
      "text": "test1",
      "created_at_utc": "2022-09-04T20:51:39+00:00"
      
    },
    {
      "text": "test2",
      "created_at_utc": "2022-09-04T20:51:18+00:00"
      
    }
  ],
  "handle_strings_value_1",
  "handle_strings_value_2"
]




@SerializedName("text")
@Expose
private String text;
@SerializedName("created_at_utc")
@Expose
private String createdAtUtc;

How do I get handle_strings_value_1 and handle_strings_value_2 there is no property name

Thanks for your help

  • It's a heterogenous array. So array elements don't have property names instead they have indexes. You can access them by their index. If the index is not guessable then you can check if the element is an object or not. if not an object then process it. – Eldar Sep 04 '22 at 21:36

1 Answers1

0

You can create a custom JsonDeserializer, to handle the issue.

The logic would be to declare the Response of the request as an array of a specific class, and create JsonDeserializer, handling the logic required. I would recommand to try to get the data in a better formatted form, since handling the data in a custom maner add complexity to your application.

You can read more about it here.

You can also check this question : Custom converter for Retrofit 2

axel7083
  • 571
  • 3
  • 16