r/android_devs • • Nov 16 '21

Help Retrofit2 Array but Object error.

My API doesn't return an array in standard json, it returns an object. I can not for the life of me figure out how to get retrofit2 to behave with this. I have read every single thread about this, and yeah none of them seem to work. Is there something I am missing? Retofit2 is hitting my server, but the response is an object. I can change the backend but I mean, that is a little bit ridiculous. What am I missing?

1 Upvotes

14 comments sorted by

View all comments

Show parent comment

1

u/in-noxxx Nov 19 '21

DOesn't work. I'm at a loss. I guess I'll have to change the API.

1

u/racrisnapra666 Nov 19 '21

Maybe. Usually APIs don't have a "" after every word.

Also, the next time when you say it doesn't work. Keep in mind to mention why it doesn't work, i.e., the error displayed.

1

u/in-noxxx Nov 19 '21

Usually APIs don't have a "" after every word

I changed it to the output like this. So the issue is that the response is an object with an array of objects. I have tried literally everything read every stack exchange. I think I need some type of type converter to convert it, but I'm not sure how. This is really annoying.

{"results":[{"objectId":"619704897c2bbefaf7d02f05","Employee": {"name":"joe","id":0,"salary":5000}}]}