Skip to content

Instantly share code, notes, and snippets.

@rsilva4-zz
Last active March 30, 2016 14:49
Show Gist options
  • Save rsilva4-zz/e22cba467be5432ef3a8631f81e9f2be to your computer and use it in GitHub Desktop.
Save rsilva4-zz/e22cba467be5432ef3a8631f81e9f2be to your computer and use it in GitHub Desktop.
Groovy Unirest ObjectMapper
Unirest.setObjectMapper(new ObjectMapper() {
JsonSlurper jsonSlurper = new JsonSlurper()
public <T> T readValue(String value, Class<T> valueType) {
try {
return jsonSlurper.parseText(value)
} catch (e) {
throw new RuntimeException(e);
}
}
public String writeValue(Object value) {
try {
return JsonOutput.toJson(value)
} catch (e) {
throw new RuntimeException(e);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment