### Question:
JSONUtils { public static String toJsonString(Object object, SerializationFeature feature) { try { ObjectWriter writer = objectMapper.writer(feature); return writer.writeValueAsString(object); } catch (Exception e) { logger.error("object to json exception!", e); } return null; } private  JSONUtils(); static ArrayNode createArrayNode(); static ObjectNode createObjectNode(); static JsonNode toJsonNode(Object obj); static String toJsonString(Object object, SerializationFeature feature); static T parseObject(String json, Class<T> clazz); static List<T> toList(String json, Class<T> clazz); static boolean checkJsonValid(String json); static String findValue(JsonNode jsonNode, String fieldName); static Map<String, String> toMap(String json); static Map<K, V> toMap(String json, Class<K> classK, Class<V> classV); static String toJsonString(Object object); static ObjectNode parseObject(String text); static ArrayNode parseArray(String text);  }### Answer:
@Test public void testToJsonString() { Map<String, Object> map = new HashMap<>(); map.put("foo", "bar"); Assert.assertEquals("{\"foo\":\"bar\"}", JSONUtils.toJsonString(map)); Assert.assertEquals(String.valueOf((Object) null), JSONUtils.toJsonString(null)); Assert.assertEquals("{\"foo\":\"bar\"}", JSONUtils.toJsonString(map, SerializationFeature.WRITE_NULL_MAP_VALUES)); }