/** * Convert this request to a JSON object, which can be used as a part of a return value. * * @return JSON object representing this base request object */ public JSONObject toJSON() { JSONObject ret = new JSONObject(); ret.put("type", type.getName()); if (targetConfig != null) { ret.put("target", targetConfig.toJSON()); } if (pathParts != null) { try { ret.put("path", getPath()); } catch (UnsupportedOperationException exp) { // Happens when request doesnt support paths } } return ret; }