@Test public void toArray_NestedMap() { String str = "[{\"str\":\"str\",\"int\":1,\"bool\":true}]"; Object[] array = JsonUtils.toArray(str); Assert.assertEquals(LinkedHashMap.class, array[0].getClass()); @SuppressWarnings("unchecked") Map<String, Object> sub = (Map<String, Object>) array[0]; Assert.assertEquals("str", sub.get("str")); Assert.assertEquals(String.class, sub.get("str").getClass()); Assert.assertEquals(new Integer(1), sub.get("int")); Assert.assertEquals(Integer.class, sub.get("int").getClass()); Assert.assertEquals(new Boolean(true), sub.get("bool")); Assert.assertEquals(Boolean.class, sub.get("bool").getClass()); }
public static Object[] toArray(String json) { return getGson().fromJson(json, new TypeToken<Object[]>() { }.getType()); }
JsonUtils { public static Object[] toArray(String json) { return getGson().fromJson(json, new TypeToken<Object[]>() { }.getType()); } }
JsonUtils { public static Object[] toArray(String json) { return getGson().fromJson(json, new TypeToken<Object[]>() { }.getType()); } private  JsonUtils(); }
JsonUtils { public static Object[] toArray(String json) { return getGson().fromJson(json, new TypeToken<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 Object[] toArray(String json) { return getGson().fromJson(json, new TypeToken<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);  }