'How to parse raw data in android kotlin using retrofit?

I have a webservice api which is having some raw data. No json structure data. And all i want to parse it. This is the response i am getting from an api.

And here is my implementation for calling the api. the above implementation gives me this error, can you please help in this.



Solution 1:[1]

So after looking around and from the last comment above, i have resolved the issue. Here is the result.

If you have non json structure in api response, you just need to replace the GsonConverterFacroty line from the retrofit client i.e

            .addConverterFactory(GsonConverterFactory.create())

with

                .addConverterFactory(ScalarsConverterFactory.create())

and that's all. You can add both if you have mix responses i.e json and non-json.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kashif Ahmad