Category : retrofit

I need to parse only one list of objects from JSON object with Retroft. Here’s my JSON file I need only "similar" array from it. Also I’ve already created POJO for elements of this array Is there a way to make this without making POJO for the rest of the JSON file? Source: Android..

Read more

Let’s say I’m getting below response from API {"success":true, "base":"EUR", "date":"2021-04-16", "rates": {"AED":4.393943,"AFN":92.83145,"ALL":123.125765,"AMD":621.059723}} and I want the last rates object to be a List of Rate class i.e. Rate(code="AED", value="4.393943"). I am using Retrofit and Gson. I know I need a Deserializer or a Type Adapter. I just don’t know how to write one. Rate ..

Read more

I am getting response of a server, when i log the response body i get the access_token right, but when i try to convert it to a jsonObject it says the string is empty! apiInterface.Login(Email,Pass).enqueue(new Callback<ResponseBody>() { @Override public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { if(response.isSuccessful()){ try { Log.d("PONSEMONSE",response.body().string()); JSONObject jsonObject = new JSONObject(response.body().string()); Log.d("LONO",jsonObject.getString("access_token")); ..

Read more

{"success":true,"rates": {"AT": {"country_name":"Austria","standard_rate":20,"reduced_rates": {"domestic flights":13,"entrance to sporting events":13,"admissions to cultural events and amusement parks":13,"firewood":13,"agricultural supplies":13}},"BE": {"country_name":"Belgium","standard_rate":21,"reduced_rates": {"some foodstuffs":12,"certain agricultural supplies":12,"social housing":12}}}} I tried, @GET("rate_list") fun getValidCountries( @Query("access_key") accessKey: String, ) : Single<Response<JsonElement>> But getting error like, Cannot construct instance of com.google.gson.JsonElement (no Creators, like default construct, exist): abstract types either need to be mapped to ..

Read more