MarketDataSpecificationJsonReader { public static List<MarketDataSpecification> buildSpecifications(String json) { try { JSONArray array = new JSONArray(json); List<MarketDataSpecification> specs = Lists.newArrayListWithCapacity(array.length()); for (int i = 0; i < array.length(); i++) { specs.add(buildSpecification(array.getJSONObject(i))); } return specs; } catch (JSONException e) { throw new IllegalArgumentException("Failed to parse MarketDataSpecification JSON", e); } }  static MarketDataSpecification buildSpecification(String json); static List<MarketDataSpecification> buildSpecifications(String json);  }
@Test public void multiple() throws JSONException { String json = "[" + LIVE_JSON + ", " + LATEST_JSON + ", " + FIXED_JSON + ", " + SNAPSHOT_JSON + "]"; List<MarketDataSpecification> specs = MarketDataSpecificationJsonReader.buildSpecifications(json); assertEquals(specs, ImmutableList.of(LIVE, LATEST, FIXED, SNAPSHOT)); }