@Test public void test_getJSONasDefaultPrettyPrintFromString() throws Exception { String errorJsonStr="{}"; String str = "{\"username\":\"testuser\",\"password\":\"testuser\"}"; String json = JSONUtil.getJSONasDefaultPrettyPrintFromString(str); assertNotEquals(errorJsonStr, json); }
public static String getJSONasDefaultPrettyPrintFromString(String obj) { ObjectMapper mapper = new ObjectMapper(); try { Object json = mapper.readValue(obj, Object.class); DefaultPrettyPrinter pp = new DefaultPrettyPrinter(); pp.indentArraysWith(DefaultPrettyPrinter.FixedSpaceIndenter.instance); return mapper.writer(pp).writeValueAsString(json); } catch (JsonProcessingException e) { return TVaultConstants.EMPTY_JSON; } catch (IOException e) { return TVaultConstants.EMPTY_JSON; } }
JSONUtil { public static String getJSONasDefaultPrettyPrintFromString(String obj) { ObjectMapper mapper = new ObjectMapper(); try { Object json = mapper.readValue(obj, Object.class); DefaultPrettyPrinter pp = new DefaultPrettyPrinter(); pp.indentArraysWith(DefaultPrettyPrinter.FixedSpaceIndenter.instance); return mapper.writer(pp).writeValueAsString(json); } catch (JsonProcessingException e) { return TVaultConstants.EMPTY_JSON; } catch (IOException e) { return TVaultConstants.EMPTY_JSON; } } }
JSONUtil { public static String getJSONasDefaultPrettyPrintFromString(String obj) { ObjectMapper mapper = new ObjectMapper(); try { Object json = mapper.readValue(obj, Object.class); DefaultPrettyPrinter pp = new DefaultPrettyPrinter(); pp.indentArraysWith(DefaultPrettyPrinter.FixedSpaceIndenter.instance); return mapper.writer(pp).writeValueAsString(json); } catch (JsonProcessingException e) { return TVaultConstants.EMPTY_JSON; } catch (IOException e) { return TVaultConstants.EMPTY_JSON; } }  }
JSONUtil { public static String getJSONasDefaultPrettyPrintFromString(String obj) { ObjectMapper mapper = new ObjectMapper(); try { Object json = mapper.readValue(obj, Object.class); DefaultPrettyPrinter pp = new DefaultPrettyPrinter(); pp.indentArraysWith(DefaultPrettyPrinter.FixedSpaceIndenter.instance); return mapper.writer(pp).writeValueAsString(json); } catch (JsonProcessingException e) { return TVaultConstants.EMPTY_JSON; } catch (IOException e) { return TVaultConstants.EMPTY_JSON; } }  static String getJSON(Object obj); static String getJSONasDefaultPrettyPrint(Object obj); static String getJSONasDefaultPrettyPrintFromString(String obj); static Object getObj(String jsonStr, Class<?> className); }
JSONUtil { public static String getJSONasDefaultPrettyPrintFromString(String obj) { ObjectMapper mapper = new ObjectMapper(); try { Object json = mapper.readValue(obj, Object.class); DefaultPrettyPrinter pp = new DefaultPrettyPrinter(); pp.indentArraysWith(DefaultPrettyPrinter.FixedSpaceIndenter.instance); return mapper.writer(pp).writeValueAsString(json); } catch (JsonProcessingException e) { return TVaultConstants.EMPTY_JSON; } catch (IOException e) { return TVaultConstants.EMPTY_JSON; } }  static String getJSON(Object obj); static String getJSONasDefaultPrettyPrint(Object obj); static String getJSONasDefaultPrettyPrintFromString(String obj); static Object getObj(String jsonStr, Class<?> className);  }