I use Retrofit2 and GSON to deserialize incoming JSON. Here is my code in Android app:
public class RestClientFactory {
private static GsonBuilder gsonBuilder = GsonUtil.gsonbuilder;
private static Gson gson;
private static OkHttpClient.Builder httpClient;
private static HttpLoggingInterceptor httpLoggingInterceptor
= new HttpLoggingInterceptor()
.setLevel(HttpLoggingInterceptor.Level.BASIC);
static {
gsonBuilder.setDateFormat(DateUtil.DATETIME_FORMAT);
httpClient = new OkHttpClient.Builder();
gson = gsonBuilder.create();
}
private static Retrofit.Builder builder = new Retrofit.Builder()
.baseUrl(BuildConfig.API_BASE_URL)
.addConverterFactory(GsonConverterFactory.create(gson))
.client(httpClient.build());
private static Retrofit retrofit = builder.build();
}
If in incoming JSON are any HTML escaped symbols, e.g. &
Retrofit is not unescaping it.
E.g. when incoming json has text:
Healh & Fitnesss
it is deserialized as is.
But I need to get this:
Healh & Fitnesss
How can I get Retrofit to automatically unescape HTML escaped synbols?