Last active
March 30, 2016 14:49
-
-
Save rsilva4-zz/e22cba467be5432ef3a8631f81e9f2be to your computer and use it in GitHub Desktop.
Groovy Unirest ObjectMapper
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() { | |
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