@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()); }
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; }
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; } }
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(); }
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); }
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);  }