@Test public void toCollection() { String str = "[\"a1\",1,true]"; Collection<Object> col = JsonUtils.toCollection(str); Object[] array = col.toArray(); Assert.assertEquals(String.class, array[0].getClass()); Assert.assertEquals("a1", array[0]); Assert.assertEquals(Integer.class, array[1].getClass()); Assert.assertEquals(1, array[1]); Assert.assertEquals(Boolean.class, array[2].getClass()); Assert.assertEquals(new Boolean(true), array[2]); }
public static <T> Collection<T> toCollection(String json) { return getGson().fromJson(json, new TypeToken<Collection<Object>>() { }.getType()); }
JsonUtils { public static <T> Collection<T> toCollection(String json) { return getGson().fromJson(json, new TypeToken<Collection<Object>>() { }.getType()); } }
JsonUtils { public static <T> Collection<T> toCollection(String json) { return getGson().fromJson(json, new TypeToken<Collection<Object>>() { }.getType()); } private  JsonUtils(); }
JsonUtils { public static <T> Collection<T> toCollection(String json) { return getGson().fromJson(json, new TypeToken<Collection<Object>>() { }.getType()); } private  JsonUtils(); static String stripComment(String source); static String toJson(Object source); static Map<String, Object> toMap(String json); static Object[] toArray(String json); static Collection<T> toCollection(String json); }
JsonUtils { public static <T> Collection<T> toCollection(String json) { return getGson().fromJson(json, new TypeToken<Collection<Object>>() { }.getType()); } private  JsonUtils(); static String stripComment(String source); static String toJson(Object source); static Map<String, Object> toMap(String json); static Object[] toArray(String json); static Collection<T> toCollection(String json);  }