Now I see that you are using GsonBuilder here... You could move this repeated logic inside it.