Java Code Examples for org.codehaus.jettison.json.JSONObject#keys()
The following examples show how to use
org.codehaus.jettison.json.JSONObject#keys() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StramWebServices.java From attic-apex-core with Apache License 2.0 | 6 votes |
@POST // not supported by WebAppProxyServlet, can only be called directly @Path(PATH_PHYSICAL_PLAN_OPERATORS + "/{operatorId:\\d+}/properties") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public JSONObject setPhysicalOperatorProperties(JSONObject request, @PathParam("operatorId") int operatorId) { init(); JSONObject response = new JSONObject(); try { @SuppressWarnings("unchecked") Iterator<String> keys = request.keys(); while (keys.hasNext()) { String key = keys.next(); String val = request.isNull(key) ? null : request.getString(key); dagManager.setPhysicalOperatorProperty(operatorId, key, val); } } catch (JSONException ex) { LOG.warn("Got JSON Exception: ", ex); } return response; }
Example 2
Source File: Question.java From batfish with Apache License 2.0 | 6 votes |
/** * Recursively look for all key, value pairs and remove keys whose value is "${{@code varName}}". * Is this fragile? To be doubly sure, we do this only for keys with a sibling key "class" that is * a Question class */ private static void recursivelyRemoveOptionalVar(JSONObject questionObject, String varName) throws JSONException { Iterator<?> iter = questionObject.keys(); while (iter.hasNext()) { String key = (String) iter.next(); Object value = questionObject.get(key); if (value instanceof String) { if (value.equals("${" + varName + "}")) { iter.remove(); } } else if (value instanceof JSONObject) { JSONObject childObject = (JSONObject) value; if (childObject.has("class")) { Object classValue = childObject.get("class"); if (classValue instanceof String && isQuestionClass((String) classValue)) { recursivelyRemoveOptionalVar(childObject, varName); } } } } }
Example 3
Source File: RunningJobManager.java From eagle with Apache License 2.0 | 6 votes |
public Map<String, Map<String, String>> parse(JSONObject object) throws JSONException { Map<String, Map<String, String>> result = new HashMap<>(); Iterator<String> keysItr = object.keys(); while (keysItr.hasNext()) { String key = keysItr.next(); result.put(key, new HashMap<>()); String value = (String) object.get(key); JSONObject jsonObject = new JSONObject(value); Map<String, String> items = result.get(key); Iterator<String> keyItemItr = jsonObject.keys(); while (keyItemItr.hasNext()) { String itemKey = keyItemItr.next(); items.put(itemKey, (String) jsonObject.get(itemKey)); } } return result; }
Example 4
Source File: RelationToJobMetaEntity.java From eagle with Apache License 2.0 | 6 votes |
private Map<String, Object> parse(String field) { Map<String, Object> items = new java.util.HashMap<>(); try { JSONObject jsonObject = new JSONObject(field); Iterator<String> keyItemItr = jsonObject.keys(); while (keyItemItr.hasNext()) { String itemKey = keyItemItr.next(); if (canParseToMap(jsonObject.getString(itemKey))) { items.put(itemKey, parse(jsonObject.getString(itemKey))); } else { items.put(itemKey, jsonObject.get(itemKey)); } } } catch (Exception e) { LOG.warn("{}", e); } return items; }
Example 5
Source File: Node.java From jettison with Apache License 2.0 | 6 votes |
public Node(Node parent, String name, JSONObject object, Convention con) throws JSONException, XMLStreamException { this.parent = parent; this.object = object; /* Should really use a _Linked_ HashMap to preserve * ordering (insert order) -- regular one has arbitrary ordering. * But there are some funky dependencies within unit tests * that will fail right now, need to investigate that bit more */ this.namespaces = new LinkedHashMap(); this.attributes = new LinkedHashMap(); con.processAttributesAndNamespaces(this, object); keys = object.keys(); this.name = con.createQName(name, this); }
Example 6
Source File: SchemaUtils.java From attic-apex-malhar with Apache License 2.0 | 5 votes |
public static Set<String> getSetOfJSONKeys(JSONObject jo) { @SuppressWarnings("unchecked") Iterator<String> keyIterator = jo.keys(); Set<String> keySet = Sets.newHashSet(); while (keyIterator.hasNext()) { keySet.add(keyIterator.next()); } return keySet; }
Example 7
Source File: GPOUtils.java From attic-apex-malhar with Apache License 2.0 | 5 votes |
/** * Converts the provided JSON into a GPOMutable object with the provided {@link FieldsDescriptor} * @param fieldsDescriptor The {@link FieldsDescriptor} to initialize the {@link GPOMutable} object with. * @param dpou The JSONObject to deserialize from. * @return The deserialized GPOMutable object. */ public static GPOMutable deserialize(FieldsDescriptor fieldsDescriptor, JSONObject dpou) { GPOMutable gpo = new GPOMutable(fieldsDescriptor); @SuppressWarnings("unchecked") Iterator<String> itr = (Iterator<String>)dpou.keys(); while (itr.hasNext()) { String field = itr.next(); setFieldFromJSON(gpo, field, dpou); } return gpo; }
Example 8
Source File: UserProfile.java From hadoop-arch-book with Apache License 2.0 | 5 votes |
private void populateMapWithLong(JSONObject jsonObject, HashMap<String, Long> hashMap) throws JSONException { Iterator keys = jsonObject.keys(); while (keys.hasNext()) { String key = keys.next().toString(); hashMap.put(key, jsonObject.getLong(key)); } }
Example 9
Source File: FormPropertiesAnalyzer.java From appinventor-extensions with Apache License 2.0 | 5 votes |
/** * Extracts a mapping from component to set of blocks used from the Form's * Scheme (.scm) file, which is actually a JSON dictionary contained within * a block comment. Any property that is expressed in the properties section * (i.e., not the default value) is considered used by the function. * * @param source Source contents of the Scheme file * @return A mapping of component type names to sets of blocks used */ public static Map<String, Set<String>> getComponentBlocksFromSchemeFile(String source) { Map<String, Set<String>> result = new HashMap<>(); JSONObject propertiesObject = parseSourceFile(source); try { Queue<JSONObject> toProcess = new LinkedList<JSONObject>(); toProcess.add(propertiesObject.getJSONObject("Properties")); while ((propertiesObject = toProcess.poll()) != null) { String type = propertiesObject.getString("$Type"); if (!result.containsKey(type)) { result.put(type, new HashSet<String>()); } Set<String> typeProps = result.get(type); Iterator<String> it = propertiesObject.keys(); while (it.hasNext()) { String key = it.next(); if (!key.startsWith("$")) { typeProps.add(key); } } if (propertiesObject.has("$Components")) { JSONArray components = propertiesObject.getJSONArray("$Components"); for (int i = 0; i < components.length(); i++) { toProcess.add(components.getJSONObject(i)); } } } } catch (JSONException e) { throw new IllegalArgumentException("Unable to parse file - invalid $JSON section syntax"); } return result; }
Example 10
Source File: JsonByteArrayOperator.java From attic-apex-malhar with Apache License 2.0 | 5 votes |
private void getFlatMap(JSONObject jSONObject, Map<String, Object> map, String keyPrefix) throws Exception { Iterator<String> iterator = jSONObject.keys(); while (iterator.hasNext()) { String key = iterator.next(); String insertKey = (keyPrefix == null) ? key : keyPrefix + CONCAT_CHAR + key; JSONObject value = jSONObject.optJSONObject(key); if (value == null) { map.put(insertKey, jSONObject.get(key)); } else { getFlatMap(value, map, insertKey); } } }
Example 11
Source File: HBaseLookupProcessor.java From datacollector with Apache License 2.0 | 5 votes |
private void updateRecord(Record record, HBaseLookupParameterConfig parameter, Pair<String, HBaseColumn> key, Optional<String> value) throws JSONException { // If the value does not exists in HBase, no updates on record if(value == null || !value.isPresent()) { LOG.debug( "No value found on Record '{}' with key:'{}', column:'{}', timestamp:'{}'", record, key.getKey(), key.getValue().getQualifiedName(), key.getValue().getTimestamp().orElse(HBaseColumn.NO_TIMESTAMP) ); return; } // if the Column Expression is empty, return the row data ( columnName + value ) if(parameter.columnExpr.isEmpty()) { JSONObject json = new JSONObject(value.get()); Iterator<String> iter = json.keys(); Map<String, Field> columnMap = new HashMap<>(); while(iter.hasNext()) { String columnName = iter.next(); String columnValue = json.get(columnName).toString(); columnMap.put(columnName, Field.create(columnValue)); } record.set(parameter.outputFieldPath, Field.create(columnMap)); } else { record.set(parameter.outputFieldPath, Field.create(value.get())); } }
Example 12
Source File: JobHistoryFileParserHadoop2.java From hraven with Apache License 2.0 | 5 votes |
/** * iterate over the event details and prepare puts * @throws JSONException */ private void iterateAndPreparePuts(JSONObject eventDetails, Put p, Hadoop2RecordType recType) throws JSONException { Iterator<?> keys = eventDetails.keys(); while (keys.hasNext()) { String key = (String) keys.next(); processAllTypes(p, recType, eventDetails, key); } }
Example 13
Source File: SimpleHistoryParser.java From tez with Apache License 2.0 | 5 votes |
private void populateOtherInfo(JSONObject source, JSONObject destination) throws JSONException { if (source == null || destination == null) { return; } for (Iterator it = source.keys(); it.hasNext(); ) { String key = (String) it.next(); Object val = source.get(key); destination.put(key, val); } }
Example 14
Source File: ApexCli.java From attic-apex-core with Apache License 2.0 | 4 votes |
@Override public void execute(String[] args, ConsoleReader reader) throws Exception { String[] newArgs = new String[args.length - 1]; System.arraycopy(args, 1, newArgs, 0, args.length - 1); GetOperatorClassesCommandLineInfo commandLineInfo = getGetOperatorClassesCommandLineInfo(newArgs); String parentName = commandLineInfo.parent != null ? commandLineInfo.parent : GenericOperator.class.getName(); String files = expandCommaSeparatedFiles(commandLineInfo.args[0]); if (files == null) { throw new CliException("File " + commandLineInfo.args[0] + " is not found"); } String[] jarFiles = files.split(","); File tmpDir = copyToLocal(jarFiles); try { OperatorDiscoverer operatorDiscoverer = new OperatorDiscoverer(jarFiles); String searchTerm = commandLineInfo.args.length > 1 ? commandLineInfo.args[1] : null; Set<String> operatorClasses = operatorDiscoverer.getOperatorClasses(parentName, searchTerm); JSONObject json = new JSONObject(); JSONArray arr = new JSONArray(); JSONObject portClassHier = new JSONObject(); JSONObject portTypesWithSchemaClasses = new JSONObject(); JSONObject failed = new JSONObject(); for (final String clazz : operatorClasses) { try { JSONObject oper = operatorDiscoverer.describeOperator(clazz); // add default value operatorDiscoverer.addDefaultValue(clazz, oper); // add class hierarchy info to portClassHier and fetch port types with schema classes operatorDiscoverer.buildAdditionalPortInfo(oper, portClassHier, portTypesWithSchemaClasses); Iterator portTypesIter = portTypesWithSchemaClasses.keys(); while (portTypesIter.hasNext()) { if (!portTypesWithSchemaClasses.getBoolean((String)portTypesIter.next())) { portTypesIter.remove(); } } arr.put(oper); } catch (Exception | NoClassDefFoundError ex) { // ignore this class final String cls = clazz; failed.put(cls, ex.toString()); } } json.put("operatorClasses", arr); json.put("portClassHier", portClassHier); json.put("portTypesWithSchemaClasses", portTypesWithSchemaClasses); if (failed.length() > 0) { json.put("failedOperators", failed); } printJson(json); } finally { FileUtils.deleteDirectory(tmpDir); } }
Example 15
Source File: ATSImportTool.java From tez with Apache License 2.0 | 4 votes |
/** * Download DAG data (DAG, Vertex, Task, TaskAttempts) from ATS and write to zip file * * @param zos * @throws TezException * @throws JSONException * @throws IOException */ private void downloadData(ZipOutputStream zos) throws TezException, JSONException, IOException { JSONObject finalJson = new JSONObject(); //Download application details (TEZ_VERSION etc) String tezAppId = "tez_" + tezDAGID.getApplicationId().toString(); String tezAppUrl = String.format("%s/%s/%s", baseUri, Constants.TEZ_APPLICATION, tezAppId); JSONObject tezAppJson = getJsonRootEntity(tezAppUrl); finalJson.put(Constants.APPLICATION, tezAppJson); //Download dag String dagUrl = String.format("%s/%s/%s", baseUri, Constants.TEZ_DAG_ID, dagId); JSONObject dagRoot = getJsonRootEntity(dagUrl); // We have added dag extra info, if we find any from ATS we copy the info into dag object // extra info. String dagExtraInfoUrl = String.format("%s/%s/%s", baseUri, EntityTypes.TEZ_DAG_EXTRA_INFO, dagId); JSONObject dagExtraInfo = getJsonRootEntity(dagExtraInfoUrl); if (dagExtraInfo.has(Constants.OTHER_INFO)) { JSONObject dagOtherInfo = dagRoot.getJSONObject(Constants.OTHER_INFO); JSONObject extraOtherInfo = dagExtraInfo.getJSONObject(Constants.OTHER_INFO); @SuppressWarnings("unchecked") Iterator<String> iter = extraOtherInfo.keys(); while (iter.hasNext()) { String key = iter.next(); dagOtherInfo.put(key, extraOtherInfo.get(key)); } } finalJson.put(Constants.DAG, dagRoot); //Create a zip entry with dagId as its name. ZipEntry zipEntry = new ZipEntry(dagId); zos.putNextEntry(zipEntry); //Write in formatted way IOUtils.write(finalJson.toString(4), zos, UTF8); //Download vertex String vertexURL = String.format(VERTEX_QUERY_STRING, baseUri, Constants.TEZ_VERTEX_ID, batchSize, Constants.TEZ_DAG_ID, dagId); downloadJSONArrayFromATS(vertexURL, zos, Constants.VERTICES); //Download task String taskURL = String.format(TASK_QUERY_STRING, baseUri, Constants.TEZ_TASK_ID, batchSize, Constants.TEZ_DAG_ID, dagId); downloadJSONArrayFromATS(taskURL, zos, Constants.TASKS); //Download task attempts String taskAttemptURL = String.format(TASK_ATTEMPT_QUERY_STRING, baseUri, Constants.TEZ_TASK_ATTEMPT_ID, batchSize, Constants.TEZ_DAG_ID, dagId); downloadJSONArrayFromATS(taskAttemptURL, zos, Constants.TASK_ATTEMPTS); }
Example 16
Source File: StramWebServices.java From attic-apex-core with Apache License 2.0 | 4 votes |
@POST // not supported by WebAppProxyServlet, can only be called directly @Path(PATH_LOGICAL_PLAN) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public JSONObject logicalPlanModification(JSONObject request) { init(); JSONObject response = new JSONObject(); try { JSONArray jsonArray = request.getJSONArray("requests"); List<LogicalPlanRequest> requests = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObj = (JSONObject)jsonArray.get(i); LogicalPlanRequest requestObj = (LogicalPlanRequest)Class.forName(LogicalPlanRequest.class.getPackage().getName() + "." + jsonObj.getString("requestType")).newInstance(); @SuppressWarnings("unchecked") Map<String, String> properties = BeanUtils.describe(requestObj); @SuppressWarnings("unchecked") Iterator<String> keys = jsonObj.keys(); while (keys.hasNext()) { String key = keys.next(); if (!key.equals("requestType")) { properties.put(key, jsonObj.get(key).toString()); } } BeanUtils.populate(requestObj, properties); requests.add(requestObj); } Future<?> fr = dagManager.logicalPlanModification(requests); fr.get(3000, TimeUnit.MILLISECONDS); } catch (Exception ex) { LOG.error("Error processing plan change", ex); try { if (ex instanceof ExecutionException) { response.put("error", ex.getCause().toString()); } else { response.put("error", ex.toString()); } } catch (Exception e) { // ignore } } return response; }
Example 17
Source File: ApexCli.java From Bats with Apache License 2.0 | 4 votes |
@Override public void execute(String[] args, ConsoleReader reader) throws Exception { String[] newArgs = new String[args.length - 1]; System.arraycopy(args, 1, newArgs, 0, args.length - 1); GetOperatorClassesCommandLineInfo commandLineInfo = getGetOperatorClassesCommandLineInfo(newArgs); String parentName = commandLineInfo.parent != null ? commandLineInfo.parent : GenericOperator.class.getName(); String files = expandCommaSeparatedFiles(commandLineInfo.args[0]); if (files == null) { throw new CliException("File " + commandLineInfo.args[0] + " is not found"); } String[] jarFiles = files.split(","); File tmpDir = copyToLocal(jarFiles); try { OperatorDiscoverer operatorDiscoverer = new OperatorDiscoverer(jarFiles); String searchTerm = commandLineInfo.args.length > 1 ? commandLineInfo.args[1] : null; Set<String> operatorClasses = operatorDiscoverer.getOperatorClasses(parentName, searchTerm); JSONObject json = new JSONObject(); JSONArray arr = new JSONArray(); JSONObject portClassHier = new JSONObject(); JSONObject portTypesWithSchemaClasses = new JSONObject(); JSONObject failed = new JSONObject(); for (final String clazz : operatorClasses) { try { JSONObject oper = operatorDiscoverer.describeOperator(clazz); // add default value operatorDiscoverer.addDefaultValue(clazz, oper); // add class hierarchy info to portClassHier and fetch port types with schema classes operatorDiscoverer.buildAdditionalPortInfo(oper, portClassHier, portTypesWithSchemaClasses); Iterator portTypesIter = portTypesWithSchemaClasses.keys(); while (portTypesIter.hasNext()) { if (!portTypesWithSchemaClasses.getBoolean((String)portTypesIter.next())) { portTypesIter.remove(); } } arr.put(oper); } catch (Exception | NoClassDefFoundError ex) { // ignore this class final String cls = clazz; failed.put(cls, ex.toString()); } } json.put("operatorClasses", arr); json.put("portClassHier", portClassHier); json.put("portTypesWithSchemaClasses", portTypesWithSchemaClasses); if (failed.length() > 0) { json.put("failedOperators", failed); } printJson(json); } finally { FileUtils.deleteDirectory(tmpDir); } }
Example 18
Source File: ApexCli.java From Bats with Apache License 2.0 | 4 votes |
@Override public void execute(String[] args, ConsoleReader reader) throws Exception { try { JSONArray jsonArray = new JSONArray(); List<ApplicationReport> appList = getApplicationList(); Collections.sort(appList, new Comparator<ApplicationReport>() { @Override public int compare(ApplicationReport o1, ApplicationReport o2) { return o1.getApplicationId().getId() - o2.getApplicationId().getId(); } }); int totalCnt = 0; int runningCnt = 0; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); for (ApplicationReport ar : appList) { /* * This is inefficient, but what the heck, if this can be passed through the command line, can anyone notice slowness. */ JSONObject jsonObj = new JSONObject(); jsonObj.put("startTime", sdf.format(new java.util.Date(ar.getStartTime()))); jsonObj.put("id", ar.getApplicationId().getId()); jsonObj.put("name", ar.getName()); jsonObj.put("state", ar.getYarnApplicationState().name()); jsonObj.put("trackingUrl", ar.getTrackingUrl()); jsonObj.put("finalStatus", ar.getFinalApplicationStatus()); JSONArray tags = new JSONArray(); for (String tag : ar.getApplicationTags()) { tags.put(tag); } jsonObj.put("tags", tags); totalCnt++; if (ar.getYarnApplicationState() == YarnApplicationState.RUNNING) { runningCnt++; } if (args.length > 1) { if (StringUtils.isNumeric(args[1])) { if (jsonObj.getString("id").equals(args[1])) { jsonArray.put(jsonObj); break; } } else { @SuppressWarnings("unchecked") Iterator<String> keys = jsonObj.keys(); while (keys.hasNext()) { if (jsonObj.get(keys.next()).toString().toLowerCase().contains(args[1].toLowerCase())) { jsonArray.put(jsonObj); break; } } } } else { jsonArray.put(jsonObj); } } printJson(jsonArray, "apps"); if (consolePresent) { System.out.println(runningCnt + " active, total " + totalCnt + " applications."); } } catch (Exception ex) { throw new CliException("Failed to retrieve application list", ex); } }
Example 19
Source File: LogicalPlanSerializer.java From Bats with Apache License 2.0 | 4 votes |
public static PropertiesConfiguration convertToProperties(JSONObject json) throws JSONException { PropertiesConfiguration props = new PropertiesConfiguration(); JSONArray allOperators = json.getJSONArray("operators"); JSONArray allStreams = json.getJSONArray("streams"); for (int j = 0; j < allOperators.length(); j++) { JSONObject operatorDetail = allOperators.getJSONObject(j); String operatorName = operatorDetail.getString("name"); String operatorKey = LogicalPlanConfiguration.OPERATOR_PREFIX + operatorName; props.setProperty(operatorKey + ".classname", operatorDetail.getString("class")); JSONObject properties = operatorDetail.optJSONObject("properties"); if (properties != null) { Iterator<String> iter2 = properties.keys(); while (iter2.hasNext()) { String propertyName = iter2.next(); if (!propertyName.equals("name") && !propertyName.equals("class") && properties.opt(propertyName) != null) { JSONArray list = properties.optJSONArray(propertyName); String value = ""; if (list != null) { for (int i = 0; i < list.length(); i++) { if (i != 0) { value += ","; } value += list.get(i).toString(); } props.setProperty(operatorKey + "." + propertyName, value); } else { props.setProperty(operatorKey + "." + propertyName, properties.get(propertyName)); } } } } } for (int j = 0; j < allStreams.length(); j++) { JSONObject streamDetail = allStreams.getJSONObject(j); String streamName = streamDetail.getString("name"); String streamKey = LogicalPlanConfiguration.STREAM_PREFIX + streamName; JSONObject sourceDetail = streamDetail.getJSONObject("source"); JSONArray sinksList = streamDetail.getJSONArray("sinks"); props.setProperty(streamKey + "." + LogicalPlanConfiguration.STREAM_SOURCE, sourceDetail.getString("operatorName") + "." + sourceDetail.getString("portName")); String sinksValue = ""; for (int i = 0; i < sinksList.length(); i++) { if (!sinksValue.isEmpty()) { sinksValue += ","; } sinksValue += sinksList.getJSONObject(i).getString("operatorName") + "." + sinksList.getJSONObject(i).getString("portName"); } props.setProperty(streamKey + "." + LogicalPlanConfiguration.STREAM_SINKS, sinksValue); String locality = streamDetail.optString("locality", null); if (locality != null) { props.setProperty(streamKey + "." + LogicalPlanConfiguration.STREAM_LOCALITY, Locality.valueOf(locality)); } } // TBD: Attributes return props; }
Example 20
Source File: StramWebServices.java From Bats with Apache License 2.0 | 4 votes |
@POST // not supported by WebAppProxyServlet, can only be called directly @Path(PATH_LOGICAL_PLAN) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public JSONObject logicalPlanModification(JSONObject request) { init(); JSONObject response = new JSONObject(); try { JSONArray jsonArray = request.getJSONArray("requests"); List<LogicalPlanRequest> requests = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObj = (JSONObject)jsonArray.get(i); LogicalPlanRequest requestObj = (LogicalPlanRequest)Class.forName(LogicalPlanRequest.class.getPackage().getName() + "." + jsonObj.getString("requestType")).newInstance(); @SuppressWarnings("unchecked") Map<String, String> properties = BeanUtils.describe(requestObj); @SuppressWarnings("unchecked") Iterator<String> keys = jsonObj.keys(); while (keys.hasNext()) { String key = keys.next(); if (!key.equals("requestType")) { properties.put(key, jsonObj.get(key).toString()); } } BeanUtils.populate(requestObj, properties); requests.add(requestObj); } Future<?> fr = dagManager.logicalPlanModification(requests); fr.get(3000, TimeUnit.MILLISECONDS); } catch (Exception ex) { LOG.error("Error processing plan change", ex); try { if (ex instanceof ExecutionException) { response.put("error", ex.getCause().toString()); } else { response.put("error", ex.toString()); } } catch (Exception e) { // ignore } } return response; }