Skip to content

Instantly share code, notes, and snippets.

@baymac
Created July 20, 2019 13:31
Show Gist options
  • Save baymac/e023afe660c19cb542baadf568eb4ab9 to your computer and use it in GitHub Desktop.
Save baymac/e023afe660c19cb542baadf568eb4ab9 to your computer and use it in GitHub Desktop.
To print JSON from a httpserverletrequest in Java
StringBuilder sb = new StringBuilder();
BufferedReader reader = request.getReader();
try {
String line;
while ((line = reader.readLine()) != null) {
sb.append(line).append('\n');
}
} finally {
reader.close();
}
LOGGER.info("JSON: " + sb.toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment