private static List<Waypoint> parseWaypoints(final ArrayNode wptsJson) { List<Waypoint> result = null; for (final JsonNode wptResponse : wptsJson) { try { final Waypoint wpt = new Waypoint( wptResponse.get(WPT_NAME).asText(), parseWptType(wptResponse.get(WPT_TYPE).asText()), false); wpt.setNote(wptResponse.get(WPT_DESCRIPTION).asText()); final Geopoint pt = parseCoords(wptResponse.get(WPT_LOCATION).asText()); if (pt != null) { wpt.setCoords(pt); } if (result == null) { result = new ArrayList<>(); } wpt.setPrefix(wpt.getName()); result.add(wpt); } catch (final NullPointerException e) { Log.e("OkapiClient.parseWaypoints", e); } } return result; }
private static List<Waypoint> parseWaypoints(final JSONArray wptsJson) { List<Waypoint> result = null; for (int i = 0; i < wptsJson.length(); i++) { try { final JSONObject wptResponse = wptsJson.getJSONObject(i); final Waypoint wpt = new Waypoint( wptResponse.getString(WPT_NAME), parseWptType(wptResponse.getString(WPT_TYPE)), false); wpt.setNote(wptResponse.getString(WPT_DESCRIPTION)); final Geopoint pt = parseCoords(wptResponse.getString(WPT_LOCATION)); if (pt != null) { wpt.setCoords(pt); } if (result == null) { result = new ArrayList<Waypoint>(); } result.add(wpt); } catch (final JSONException e) { Log.e("OkapiClient.parseWaypoints", e); } } return result; }