private void respond(Iterator<String> words, String cmd, String id) {
    JSONArray array = new JSONArray();
    if (words != null) {
      while (words.hasNext()) array.put(words.next());
    }

    JSONObject response = new JSONObject();
    try {
      response.put("id", id);
      response.put("error", (String) null);
      response.put("result", array);
      setResponse(response.toString());
    } catch (JSONException e) {
      jsonError("Failed to construct response");
    }
  }
Esempio n. 2
0
 // This is used by src/main/bin/config-doc.sh which is used by
 // src/main/bin/traffic_monitor_config.pl which must be run after rpm install of traffic monitor
 @SuppressWarnings("PMD")
 public static void main(final String[] args) throws JSONException {
   final JSONObject doc = ConfigHandler.getConfig().getConfigDoc();
   System.out.println(doc.toString(2));
 }