JacksonUtil { public static String writeValueAsString(Object obj) { try { return getInstance().writeValueAsString(obj); } catch (JsonGenerationException e) { logger.error(e.getMessage(), e); } catch (JsonMappingException e) { logger.error(e.getMessage(), e); } catch (IOException e) { logger.error(e.getMessage(), e); } return null; }  static ObjectMapper getInstance(); static String writeValueAsString(Object obj); static T readValue(String jsonStr, Class<T> clazz); static T readValue(String jsonStr, Class<?> parametrized, Class<?>... parameterClasses);  }
@Test public void shouldWriteValueAsString() { Map<String, String> map = new HashMap<>(); map.put("aaa", "111"); map.put("bbb", "222"); String json = writeValueAsString(map); assertThat(json, is("{\"aaa\":\"111\",\"bbb\":\"222\"}")); }