Skip to content

Instantly share code, notes, and snippets.

@ilopez
Created March 25, 2016 15:54
Show Gist options
  • Save ilopez/751412e92642186d9be0 to your computer and use it in GitHub Desktop.
Save ilopez/751412e92642186d9be0 to your computer and use it in GitHub Desktop.
Using Gson with Unirest
Unirest.setObjectMapper(new ObjectMapper() {
private Gson gson = new Gson();
public <T> T readValue(String s, Class<T> aClass) {
try{
return gson.fromJson(s, aClass);
}catch(Exception e){
throw new RuntimeException(e);
}
}
public String writeValue(Object o) {
try{
return gson.toJson(o);
}catch(Exception e){
throw new RuntimeException(e);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment