@Test public void testWriteJsonToJavaObject(){ String jsonString = "[\"hdfs\",\"hive\",\"knox\"]"; Set<String> expectedSet = new HashSet<String>(); expectedSet.add("hive"); expectedSet.add("hdfs"); expectedSet.add("knox"); Set<String> testSet = new HashSet<>(); Set<String> actualSet = jsonUtil.writeJsonToJavaObject(jsonString, testSet.getClass()); Assert.assertEquals(expectedSet, actualSet); }
public <T> T writeJsonToJavaObject(String json, Class<T> tClass) { try { return JsonUtilsV2.jsonToObj(json, tClass); } catch (Exception e) { throw restErrorUtil.createRESTException("Invalid input data: " + e.getMessage(), MessageEnums.INVALID_INPUT_DATA); } }
JSONUtil { public <T> T writeJsonToJavaObject(String json, Class<T> tClass) { try { return JsonUtilsV2.jsonToObj(json, tClass); } catch (Exception e) { throw restErrorUtil.createRESTException("Invalid input data: " + e.getMessage(), MessageEnums.INVALID_INPUT_DATA); } } }
JSONUtil { public <T> T writeJsonToJavaObject(String json, Class<T> tClass) { try { return JsonUtilsV2.jsonToObj(json, tClass); } catch (Exception e) { throw restErrorUtil.createRESTException("Invalid input data: " + e.getMessage(), MessageEnums.INVALID_INPUT_DATA); } }  }
JSONUtil { public <T> T writeJsonToJavaObject(String json, Class<T> tClass) { try { return JsonUtilsV2.jsonToObj(json, tClass); } catch (Exception e) { throw restErrorUtil.createRESTException("Invalid input data: " + e.getMessage(), MessageEnums.INVALID_INPUT_DATA); } }  File writeJsonToFile(ViewBaseBean viewBean, String fileName); Map<String, String> jsonToMap(String jsonStr); String readMapToString(Map<?, ?> map); String readListToString(List<?> list); String writeObjectAsString(Serializable obj); T writeJsonToJavaObject(String json, Class<T> tClass); }
JSONUtil { public <T> T writeJsonToJavaObject(String json, Class<T> tClass) { try { return JsonUtilsV2.jsonToObj(json, tClass); } catch (Exception e) { throw restErrorUtil.createRESTException("Invalid input data: " + e.getMessage(), MessageEnums.INVALID_INPUT_DATA); } }  File writeJsonToFile(ViewBaseBean viewBean, String fileName); Map<String, String> jsonToMap(String jsonStr); String readMapToString(Map<?, ?> map); String readListToString(List<?> list); String writeObjectAsString(Serializable obj); T writeJsonToJavaObject(String json, Class<T> tClass);  }