public static String prettyJson(ObjectMapper mapper, String jsonString) {
        try {
            Object jsonObject = mapper.readValue(jsonString, Object.class);
            return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonObject);
        } catch (JsonParseException e) {
            log.debug("JsonParseException caused by {}", e);
        } catch (JsonMappingException e) {
            log.debug("JsonMappingException caused by {}", e);
        } catch (JsonProcessingException e) {
            log.debug("JsonProcessingException caused by {}", e);
        }
        return null;
    }
@Test
    public void testPrettyJson() {
        String string = prettyJson(new ObjectMapper(), "{\"json\":\"json\"}");
        String prettyJsonString = "{\n  \"json\" : \"json\"\n}";
        assertEquals(string, prettyJsonString);

        assertNull(prettyJson(new ObjectMapper(), "{\"json\":\"json\""));
        assertNull(prettyJson(new ObjectMapper(), "{\"json\"\"json\"}"));
    }