/** * Put a value in the JSONArray, where the value will be a * JSONArray which is produced from a Collection. * @param value A Collection value. * @return this. */ public JSONArray put(final Collection value) { put(new JSONArray(value)); return this; }
/** * Put a value in the JSONArray, where the value will be a * JSONArray which is produced from a Collection. * @param value A Collection value. * @return this. */ public JSONArray put(final Collection value) { put(new JSONArray(value)); return this; }
/** * Put a value in the JSONArray, where the value will be a * JSONArray which is produced from a Collection. * @param index The subscript. * @param value A Collection value. * @return this. * @throws JSONException If the index is negative or if the value is * not finite. */ public JSONArray put(final int index, final Collection value) throws JSONException { put(index, new JSONArray(value)); return this; }
/** * Put a key/value pair in the JSONObject, where the value will be a * JSONArray which is produced from a Collection. * @param key A key string. * @param value A Collection value. * @return this. * @throws JSONException */ public JSONObject put(final String key, final Collection value) throws JSONException { put(key, new JSONArray(value)); return this; }
/** * Put a key/value pair in the JSONObject, where the value will be a * JSONArray which is produced from a Collection. * @param key A key string. * @param value A Collection value. * @return this. * @throws JSONException */ public JSONObject put(final String key, final Collection value) throws JSONException { put(key, new JSONArray(value)); return this; }
/** * Used by HornetQ management service. */ public static Map<String, Object> fromCommaSeparatedKeyValues(final String str) throws Exception { if (str == null || str.trim().length() == 0) { return Collections.emptyMap(); } // create a JSON array with 1 object: JSONArray array = new JSONArray("[{" + str + "}]"); Map<String, Object> params = (Map<String, Object>) ManagementHelper.fromJSONArray(array)[0]; return params; }
/** * Used by HornetQ management service. */ public static Map<String, Object> fromCommaSeparatedKeyValues(final String str) throws Exception { if (str == null || str.trim().length() == 0) { return Collections.emptyMap(); } // create a JSON array with 1 object: JSONArray array = new JSONArray("[{" + str + "}]"); Map<String, Object> params = (Map<String, Object>)ManagementHelper.fromJSONArray(array)[0]; return params; }
/** * Put a value in the JSONArray, where the value will be a * JSONArray which is produced from a Collection. * @param index The subscript. * @param value A Collection value. * @return this. * @throws JSONException If the index is negative or if the value is * not finite. */ public JSONArray put(final int index, final Collection value) throws JSONException { put(index, new JSONArray(value)); return this; }
private static JSONArray toJSONMsgArray(final Map<String, Object>[] messages) { JSONArray array = new JSONArray(); for (Map<String, Object> message : messages) { array.put(new JSONObject(message)); } return array; }
/** * Produce a JSONArray containing the names of the elements of this * JSONObject. * @return A JSONArray containing the key strings, or null if the JSONObject * is empty. */ public JSONArray names() { JSONArray ja = new JSONArray(); Iterator keys = keys(); while (keys.hasNext()) { ja.put(keys.next()); } return ja.length() == 0 ? null : ja; }
/** * Produce a JSONArray containing the names of the elements of this * JSONObject. * @return A JSONArray containing the key strings, or null if the JSONObject * is empty. */ public JSONArray names() { JSONArray ja = new JSONArray(); Iterator keys = keys(); while (keys.hasNext()) { ja.put(keys.next()); } return ja.length() == 0 ? null : ja; }
public String listProducersInfoAsJSON() throws Exception { JSONArray producers = new JSONArray(); for (ServerSession session : server.getSessions()) { session.describeProducersInfo(producers); } return producers.toString(); }
public String listProducersInfoAsJSON() throws Exception { JSONArray producers = new JSONArray(); for (ServerSession session : server.getSessions()) { session.describeProducersInfo(producers); } return producers.toString(); }
static String toJSON(final Map<String, Object>[] messages) { JSONArray array = new JSONArray(); for (Map<String, Object> message : messages) { array.put(new JSONObject(message)); } return array.toString(); }
private static String toJSON(final Map<String, Object>[] messages) { JSONArray array = new JSONArray(); for (Map<String, Object> message : messages) { array.put(new JSONObject(message)); } return array.toString(); }
/** * Used by HornetQ management service. */ public static Object[] retrieveOperationParameters(final Message message) throws Exception { SimpleString sstring = message.getBodyBuffer().readNullableSimpleString(); String jsonString = (sstring == null) ? null : sstring.toString(); if (jsonString != null) { JSONArray jsonArray = new JSONArray(jsonString); return ManagementHelper.fromJSONArray(jsonArray); } else { return null; } }
public static JMSSessionInfo[] from(final String jsonString) throws JSONException { JSONArray array = new JSONArray(jsonString); JMSSessionInfo[] infos = new JMSSessionInfo[array.length()]; for (int i = 0; i < array.length(); i++) { JSONObject obj = array.getJSONObject(i); JMSSessionInfo info = new JMSSessionInfo(obj.getString("sessionID"), obj.getLong("creationTime")); infos[i] = info; } return infos; }
public static String toJSON(final DayCounterInfo[] infos) throws JSONException { JSONObject json = new JSONObject(); JSONArray counters = new JSONArray(); for (DayCounterInfo info : infos) { JSONObject counter = new JSONObject(); counter.put("date", info.getDate()); counter.put("counters", Arrays.asList(info.getCounters())); counters.put(counter); } json.put("dayCounters", counters); return json.toString(); }
public String getRolesAsJSON(final String addressMatch) throws Exception { checkStarted(); clearIO(); try { JSONArray json = new JSONArray(); Set<Role> roles = server.getSecurityRepository().getMatch(addressMatch); for (Role role : roles) { json.put(new JSONObject(role)); } return json.toString(); } finally { blockOnIO(); } }
public static JMSConnectionInfo[] from(final String jsonString) throws Exception { JSONArray array = new JSONArray(jsonString); JMSConnectionInfo[] infos = new JMSConnectionInfo[array.length()]; for (int i = 0; i < array.length(); i++) { JSONObject obj = array.getJSONObject(i); String cid = obj.isNull("clientID") ? null : obj.getString("clientID"); String uname = obj.isNull("principal") ? null : obj.getString("principal"); JMSConnectionInfo info = new JMSConnectionInfo(obj.getString("connectionID"), obj.getString("clientAddress"), obj.getLong("creationTime"), cid, uname); infos[i] = info; } return infos; }