Reputation: 133
I have that json
[
{
TITLE: "Yoy’s Child"
},
TITLE: "Look at me – Stop looking"
}
]
I use retrofit and gson and the results are
Yoy’s Child
Look at me – Stop looking
The problem is encoding that special characters. Here's my code
GsonBuilder gsonBuilder = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
return new Date(json.getAsJsonPrimitive().getAsLong());
}
});
gson = gsonBuilder.create();
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint(WEB_URL)
.setConverter(new GsonConverter(gson))
.build();
apiService = restAdapter.create(APIService.class);
Upvotes: 0
Views: 1506
Reputation: 133
I solved it. I debugged the application and found out that the return json had the symbol issues. All I had to do was just to encode json to UTF-8.
Upvotes: 0
Reputation: 1012
Try adding the disableHtmlEscaping command to the GsonBuilder constructor.
GsonBuilder gsonBuilder = new GsonBuilder().disableHtmlEscaping();
Upvotes: 2