@Test public void testGetList() throws Exception { List<TestObj> list = WXJsonUtils.getList("[{'a':1},{'a':2}]",TestObj.class); assertEquals(list.size(),2); assertEquals(list.get(0).getA(),1); assertEquals(list.get(1).getA(),2); list = WXJsonUtils.getList("{}",TestObj.class); assertEquals(list.size(),0); }
public @NonNull static <T> List<T> getList(String json, Class<T> clazz) { List<T> result = null; try { result = JSONObject.parseArray(json, clazz); } catch (Exception e) { e.printStackTrace(); result = new ArrayList<>(); } return result; }
WXJsonUtils { public @NonNull static <T> List<T> getList(String json, Class<T> clazz) { List<T> result = null; try { result = JSONObject.parseArray(json, clazz); } catch (Exception e) { e.printStackTrace(); result = new ArrayList<>(); } return result; } }
WXJsonUtils { public @NonNull static <T> List<T> getList(String json, Class<T> clazz) { List<T> result = null; try { result = JSONObject.parseArray(json, clazz); } catch (Exception e) { e.printStackTrace(); result = new ArrayList<>(); } return result; }  }
WXJsonUtils { public @NonNull static <T> List<T> getList(String json, Class<T> clazz) { List<T> result = null; try { result = JSONObject.parseArray(json, clazz); } catch (Exception e) { e.printStackTrace(); result = new ArrayList<>(); } return result; }  @NonNull static List<T> getList(String json, Class<T> clazz); @NonNull static String fromObjectToJSONString(Object obj, boolean WriteNonStringKeyAsString); @NonNull static String fromObjectToJSONString(Object obj); static void putAll(Map<String, Object> container, JSONObject rawValue); }
WXJsonUtils { public @NonNull static <T> List<T> getList(String json, Class<T> clazz) { List<T> result = null; try { result = JSONObject.parseArray(json, clazz); } catch (Exception e) { e.printStackTrace(); result = new ArrayList<>(); } return result; }  @NonNull static List<T> getList(String json, Class<T> clazz); @NonNull static String fromObjectToJSONString(Object obj, boolean WriteNonStringKeyAsString); @NonNull static String fromObjectToJSONString(Object obj); static void putAll(Map<String, Object> container, JSONObject rawValue);  }