+ /**
+ * Primary access point to parsed JSON data, including the call to retrieve and
+ * parsing.
+ *
+ * @param url request url; if null, getUrl(ids) will be used
+ * @param ids optional; may be null
+ * @param msDelay -1 for default delay
+ * @param mode map, array, or array iterator
+ * @param mapKey an optional key for an outer map
+ * @return a Map, List, Iterator, or null
+ * @throws IOException
+ * @throws ParseException
+ *
+ * @author Bob Hanson 2019
+ */
+ @SuppressWarnings("unchecked")
+ protected Object getJSON(URL url, List<String> ids, int msDelay, int mode, String mapKey) throws IOException, ParseException {
+
+ if (url == null)
+ url = getUrl(ids);
+
+ Platform.timeCheck("EnsembleRestClient.getJSON0 " + url, Platform.TIME_MARK);
+
+ Reader br = null;
+ try {
+ br = (url == null ? null : getHttpResponse(url, ids, msDelay));
+
+ Platform.timeCheck("EnsembleRestClient.getJSON1 parsing... ", Platform.TIME_MARK);
+
+ Object ret = (br == null ? null : JSONUtils.parse(br));
+
+ Platform.timeCheck("EnsembleRestClient.getJSON2 ...done ", Platform.TIME_MARK);
+
+ if (ret != null && mapKey != null)
+ ret = ((Map<String, Object>) ret).get(mapKey);
+ if (ret == null)
+ {
+ return null;
+ }
+ switch (mode) {
+ case MODE_ARRAY:
+ case MODE_MAP:
+ break;
+ case MODE_ITERATOR:
+ ret = ((List<Object>) ret).iterator();
+ break;
+ }
+ return ret;
+
+ } finally
+ {
+ if (br != null)
+ {
+ try
+ {
+ br.close();
+ } catch (IOException e)
+ {
+ // ignore
+ }
+ }
+ }
+ }
+
+
+