### Question:
JSONUtils { public static <T> List<T> toList(String json, Class<T> clazz) { if (StringUtils.isEmpty(json)) { return Collections.emptyList(); } try { CollectionType listType = objectMapper.getTypeFactory().constructCollectionType(ArrayList.class, clazz); return objectMapper.readValue(json, listType); } catch (Exception e) { logger.error("parse list exception!", e); } return Collections.emptyList(); } 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 String2MapTest() { String str = list2String(); List<LinkedHashMap> maps = JSONUtils.toList(str, LinkedHashMap.class); Assert.assertEquals(1, maps.size()); Assert.assertEquals("mysql200", maps.get(0).get("mysql service name")); Assert.assertEquals("192.168.xx.xx", maps.get(0).get("mysql address")); Assert.assertEquals("3306", maps.get(0).get("port")); Assert.assertEquals("80", maps.get(0).get("no index of number")); Assert.assertEquals("190", maps.get(0).get("database client connections")); }
@Test public void testToList() { Assert.assertEquals(new ArrayList(), JSONUtils.toList("A1B2C3", null)); Assert.assertEquals(new ArrayList(), JSONUtils.toList("", null)); }