private static String prettyJson(String responseBody) throws ScriptException {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine scriptEngine = manager.getEngineByName("JavaScript");
scriptEngine.put("jsonString", responseBody);
scriptEngine.eval("result = JSON.stringify(JSON.parse(jsonString), null, 2)");
return (String) scriptEngine.get("result");
}
No hay comentarios:
Publicar un comentario