Retrofit 2 — Supporting JSON and XML Responses Concurrently

One of Retrofit's best features is the support of many data formats. It doesn't matter if the server expects and sends XML, JSON or protocol buffer as data format. Once you've configured an appropriate converter, any data format works flawlessly. However, what do you do if your app needs to communicate with JSON and XML endpoints at the same time?

By default, due to the behavior of the Gson (for JSON) and SimpleXML (for XML) converters, you cannot have one Retrofit instance, which supports both at the same time. In this tutorial you'll learn how to cope with this limitation and introduce support for JSON and XML in one converter with one Retrofit instance. This approach can also be customized for any other combination of data formats!

Retrofit Series Overview


Continue reading

University Enrollment Required

Future Students benefit from value packed videos and tutorials.

Enroll to receive exclusive content or sign in if you’re already a Future Student.

Enroll me for $15/mo

Explore the Library

Find interesting tutorials and solutions for your problems.

Miscellaneous