Created
March 25, 2016 15:54
-
-
Save ilopez/751412e92642186d9be0 to your computer and use it in GitHub Desktop.
Using Gson with Unirest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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