### Question:
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);  }### Answer:
@Test public void toArray() { String str = "[\"a1\",1,true]"; Object[] array = JsonUtils.toArray(str); 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]); }
@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()); }