@Test (expected = org.json.JSONException.class) public void testInvalidJson4() { ServiceData.fromJsonString("{ \"foo\": 12 }"); }
static ServiceData fromJsonString(final String jsonString) { if (jsonString == null || jsonString.isEmpty()) { throw new IllegalArgumentException("json string can not be null or empty"); } final List<Endpoint> endpoints = new ArrayList<>(); final JSONObject json = new JSONObject(jsonString); final JSONArray epList = json.getJSONArray("endpoints"); for (int i = 0; i < epList.length(); i++) { endpoints.add(Endpoint.fromJson(epList.getJSONObject(i).toString())); } return new ServiceData(endpoints); }
ServiceData { static ServiceData fromJsonString(final String jsonString) { if (jsonString == null || jsonString.isEmpty()) { throw new IllegalArgumentException("json string can not be null or empty"); } final List<Endpoint> endpoints = new ArrayList<>(); final JSONObject json = new JSONObject(jsonString); final JSONArray epList = json.getJSONArray("endpoints"); for (int i = 0; i < epList.length(); i++) { endpoints.add(Endpoint.fromJson(epList.getJSONObject(i).toString())); } return new ServiceData(endpoints); } }
ServiceData { static ServiceData fromJsonString(final String jsonString) { if (jsonString == null || jsonString.isEmpty()) { throw new IllegalArgumentException("json string can not be null or empty"); } final List<Endpoint> endpoints = new ArrayList<>(); final JSONObject json = new JSONObject(jsonString); final JSONArray epList = json.getJSONArray("endpoints"); for (int i = 0; i < epList.length(); i++) { endpoints.add(Endpoint.fromJson(epList.getJSONObject(i).toString())); } return new ServiceData(endpoints); } ServiceData();   ServiceData(final List<Endpoint> endpointList); }
ServiceData { static ServiceData fromJsonString(final String jsonString) { if (jsonString == null || jsonString.isEmpty()) { throw new IllegalArgumentException("json string can not be null or empty"); } final List<Endpoint> endpoints = new ArrayList<>(); final JSONObject json = new JSONObject(jsonString); final JSONArray epList = json.getJSONArray("endpoints"); for (int i = 0; i < epList.length(); i++) { endpoints.add(Endpoint.fromJson(epList.getJSONObject(i).toString())); } return new ServiceData(endpoints); } ServiceData();   ServiceData(final List<Endpoint> endpointList); Endpoint getEndpoint(final String name); boolean addEndpoint(final Endpoint endpoint); boolean removeEndpoint(final Endpoint endpoint); }
ServiceData { static ServiceData fromJsonString(final String jsonString) { if (jsonString == null || jsonString.isEmpty()) { throw new IllegalArgumentException("json string can not be null or empty"); } final List<Endpoint> endpoints = new ArrayList<>(); final JSONObject json = new JSONObject(jsonString); final JSONArray epList = json.getJSONArray("endpoints"); for (int i = 0; i < epList.length(); i++) { endpoints.add(Endpoint.fromJson(epList.getJSONObject(i).toString())); } return new ServiceData(endpoints); } ServiceData();   ServiceData(final List<Endpoint> endpointList); Endpoint getEndpoint(final String name); boolean addEndpoint(final Endpoint endpoint); boolean removeEndpoint(final Endpoint endpoint);  }