Convert { public static List<Multimap<String, Object>> anyJsonToJava(String json) { List<Multimap<String, Object>> result = Lists.newArrayList(); try (JsonReader reader = new JsonReader(new StringReader(json))) { reader.setLenient(true); if(reader.peek() == JsonToken.BEGIN_ARRAY) { try { reader.beginArray(); while (reader.peek() != JsonToken.END_ARRAY) { result.add(jsonToJava(reader)); } reader.endArray(); } catch (IllegalStateException e) { throw new JsonParseException(e.getMessage()); } } else { result.add(jsonToJava(reader)); } } catch (IOException e) { throw CheckedExceptions.wrapAsRuntimeException(e); } return result; } private  Convert(); static List<Multimap<String, Object>> anyJsonToJava(String json); static TObject javaToThrift(Object object); static Multimap<String, Object> jsonToJava(String json); @SuppressWarnings("unchecked") static String mapsToJson(Collection<Multimap<String, Object>> list); static String mapToJson(Map<String, ?> map); static String mapToJson(Multimap<String, Object> map); static String operatorToString(Operator operator); @SuppressWarnings("unchecked") static T possibleThriftToJava(Object tobject); static Object stringToJava(String value); static Operator stringToOperator(String symbol); static String stringToResolvableLinkInstruction(String ccl); @Deprecated static String stringToResolvableLinkSpecification(String key,
            String rawValue); static Object thriftToJava(TObject object); static Object toFunctionOrUnescapedValueIfPossible(Object value);  }
@Test public void testConvertJsonArrayWithManyObjects() { String spec = "{\"foo\": 1, \"bar\": true, \"car\": [\"a\", 1, 2]}"; int count = Random.getScaleCount(); String json = "["; for (int i = 0; i < count; i++) { json += spec + ","; } json += "]"; json = json.replace(",]", "]"); List<Multimap<String, Object>> data = Convert.anyJsonToJava(json); Assert.assertEquals(count, data.size()); }
@Test public void testConvertJsonArrayReproA() { String json = "[{\"id\":34,\"handle\":\".tp-caption.medium_bg_orange\",\"settings\":\"{\\\"hover\\\":\\\"false\\\"}\",\"hover\":\"\",\"params\":'{\"color\":\"rgb(255, 255, 255)\",\"font-size\":\"20px\",\"line-height\":\"20px\",\"font-weight\":\"800\",\"font-family\":\"\\\"Open Sans\\\"\",\"text-decoration\":\"none\",\"padding\":\"10px\",\"background-color\":\"rgb(243, 156, 18)\",\"border-width\":\"0px\",\"border-color\":\"rgb(255, 214, 88)\",\"border-style\":\"none\"}',\"__table\":\"wp_revslider_css\"}]"; Convert.anyJsonToJava(json); Assert.assertTrue(true); }