Untitled
unknown
plain_text
13 days ago
975 B
5
Indexable
// With this code that handles different JSON structures JSON services = json.get("services"); if (services.hasField("linear")) { Object linearObj = services.get("linear"); // Handling different possible types of the linear field if (linearObj instanceof JSONArray) { JSONArray linearArray = (JSONArray) linearObj; if (linearArray.length() > 0) { JSON firstLinear = linearArray.getJSONObject(0); // Continue with your logic } } else if (linearObj instanceof List) { List<?> linearList = (List<?>) linearObj; if (!linearList.isEmpty()) { JSON firstLinear = (JSON) linearList.get(0); // Continue with your logic } } } // Add this line to cast the response to IPVSResponse IPVSResponse ipvsResponse = (IPVSResponse) response; // OR if there's a conversion method: // IPVSResponse ipvsResponse = response.asIPVSResponse();
Editor is loading...
Leave a Comment