Skip to content

Instantly share code, notes, and snippets.

@emmettbutler
Created April 19, 2013 21:02
Show Gist options
  • Save emmettbutler/5423202 to your computer and use it in GitHub Desktop.
Save emmettbutler/5423202 to your computer and use it in GitHub Desktop.
private String JsonEncode(Map<String, Object> map){
ObjectMapper mapper = new ObjectMapper();
String ret = null;
try {
StringWriter strWriter = new StringWriter();
mapper.writeValue(strWriter, map);
ret = strWriter.toString();
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment