/** * Append a boolean value. This increases the array's length by one. * * @param value A boolean value. * @return this. */ public JSONArray put(boolean value) { put(value ? Boolean.TRUE : Boolean.FALSE); return this; }
/** * Put or replace a boolean value in the JSONArray. If the index is greater * than the length of the JSONArray, then null elements will be added as * necessary to pad it out. * @param index The subscript. * @param value A boolean value. * @return this. * @throws JSONException If the index is negative. */ public JSONArray put(int index, boolean value) throws JSONException { put(index, value ? Boolean.TRUE : Boolean.FALSE); return this; }
/** * Append an long value. This increases the array's length by one. * * @param value A long value. * @return this. */ public JSONArray put(long value) { put(new Long(value)); return this; }
/** * Append an int value. This increases the array's length by one. * * @param value An int value. * @return this. */ public JSONArray put(int value) { put(new Integer(value)); return this; }
/** * Put or replace an int value. If the index is greater than the length of * the JSONArray, then null elements will be added as necessary to pad * it out. * @param index The subscript. * @param value An int value. * @return this. * @throws JSONException If the index is negative. */ public JSONArray put(int index, int value) throws JSONException { put(index, new Integer(value)); return this; }
/** * Put or replace a long value. If the index is greater than the length of * the JSONArray, then null elements will be added as necessary to pad * it out. * @param index The subscript. * @param value A long value. * @return this. * @throws JSONException If the index is negative. */ public JSONArray put(int index, long value) throws JSONException { put(index, new Long(value)); return this; }
/** * Put or replace a double value. If the index is greater than the length of * the JSONArray, then null elements will be added as necessary to pad * it out. * @param index The subscript. * @param value A double value. * @return this. * @throws JSONException If the index is negative or if the value is * not finite. */ public JSONArray put(int index, double value) throws JSONException { put(index, new Double(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(Collection<?> value) { put(new JSONArray(value)); return this; }
/** Decide whether o must be skipped and added to a, when rendering a JSONObject */ private boolean skipChildObject(JSONArray a, Options opt, String key, Object value) { if(opt.arraysForChildren && (value instanceof JSONObject)) { a.put(new NamedJSONObject(key, (JSONObject)value, opt)); return true; } return false; }
/** * Put a value in the JSONArray, where the value will be a * JSONObject which is produced from a Map. * @param value A Map value. * @return this. */ public JSONArray put(Map<String, ?> value) { put(new JSONObject(value)); return this; }
/** * Append a double value. This increases the array's length by one. * * @param value A double value. * @throws JSONException if the value is not finite. * @return this. */ public JSONArray put(double value) throws JSONException { Double d = new Double(value); JSONObject.testValidity(d); put(d); return this; }
/** * Put a value in the JSONArray, where the value will be a * JSONObject which is produced from a Map. * @param index The subscript. * @param value The Map value. * @return this. * @throws JSONException If the index is negative or if the the value is * an invalid number. */ public JSONArray put(int index, Map<String, ?> value) throws JSONException { put(index, new JSONObject(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(int index, Collection<?> value) throws JSONException { put(index, new JSONArray(value)); return this; }
private void addPluginsResource(JSONArray pluginContentJSON, Iterable<String> plugins) throws JSONException { Iterator<String> pluginContentIterator = plugins.iterator(); while (pluginContentIterator.hasNext()) { String plugin = pluginContentIterator.next(); JSONObject updatePluginJSON = new JSONObject(); updatePluginJSON.put(PLUGIN_ITEM_KEY, plugin); pluginContentJSON.put(updatePluginJSON); } }
/** * 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<String> keys = keys(); while (keys.hasNext()) { ja.put(keys.next()); } return ja.length() == 0 ? null : ja; }
public JSONArray getCustomPropertiesAsJSON() throws JSONException { final JSONArray jsonArray = new JSONArray(); for (String customProperty : customProperties) { final JSONObject jsonObject = new JSONObject(); jsonObject.put(RELATIVE_PROPERTY_PATH, customProperty); jsonArray.put(jsonObject); } return jsonArray; }
@Activate protected void activate(Map<String, Object> config) throws JSONException { Map<String, String> components = ParameterUtil.toMap(PropertiesUtil.toStringArray(config.get(PROP_COMPONENTS), DEFAULT_COMPONENTS),"="); JSONArray array = new JSONArray(); for (Map.Entry<String, String> entry : components.entrySet()) { JSONObject obj = new JSONObject(); obj.put("propertyName", entry.getKey()); obj.put("componentPath", entry.getValue()); array.put(obj); } this.json = new JSONObject(); json.put("components", array); }
/** * Collect responsive JSON metadata for all renditions as image sources. * @param media Media * @return JSON metadata */ protected JSONArray getResponsiveImageSources(Media media) { Collection<Rendition> renditions = media.getRenditions(); JSONArray sources = new JSONArray(); for (Rendition rendition : renditions) { sources.put(toReponsiveImageSource(media, rendition)); } return sources; }
private void decorateEdge(JSONArray inputArray, StreamEdge inEdge, int mappedInputID) throws JSONException { JSONObject input = new JSONObject(); inputArray.put(input); input.put(ID, mappedInputID); input.put(SHIP_STRATEGY, inEdge.getPartitioner()); input.put(SIDE, (inputArray.length() == 0) ? "first" : "second"); }
private JSONArray convertResponseToJson(List<ReplicationResult> list) throws JSONException { JSONArray arr = new JSONArray(); for (ReplicationResult result : list) { JSONObject resultObject = new JSONObject(); resultObject.put("path", result.getPath()); resultObject.put("status", result.getStatus().name()); resultObject.put("version", result.getVersion()); arr.put(resultObject); } return arr; }