本文整理了Java中org.apache.sling.commons.json.JSONArray.put()
方法的一些代码示例,展示了JSONArray.put()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONArray.put()
方法的具体详情如下:
包路径:org.apache.sling.commons.json.JSONArray
类名称:JSONArray
方法名:put
[英]Append a double value. This increases the array's length by one.
[中]附加一个双精度值。这将使阵列的长度增加1。
代码示例来源:origin: org.apache.sling/org.apache.sling.commons.json
/**
* 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;
}
代码示例来源:origin: org.apache.sling/org.apache.sling.commons.json
/**
* 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;
}
代码示例来源:origin: org.apache.sling/org.apache.sling.commons.json
/**
* 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;
}
代码示例来源:origin: org.apache.sling/org.apache.sling.commons.json
/**
* 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;
}
代码示例来源:origin: org.apache.sling/org.apache.sling.commons.json
/**
* 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;
}
代码示例来源:origin: org.apache.sling/org.apache.sling.commons.json
/**
* 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;
}
代码示例来源:origin: org.apache.sling/org.apache.sling.commons.json
/**
* 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;
}
代码示例来源:origin: org.apache.sling/org.apache.sling.commons.json
/**
* 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;
}
代码示例来源:origin: org.apache.sling/org.apache.sling.commons.json
/** 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;
}
代码示例来源:origin: org.apache.sling/org.apache.sling.commons.json
/**
* 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;
}
代码示例来源:origin: org.apache.sling/org.apache.sling.commons.json
/**
* 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;
}
代码示例来源:origin: org.apache.sling/org.apache.sling.commons.json
/**
* 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;
}
代码示例来源:origin: org.apache.sling/org.apache.sling.commons.json
/**
* 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;
}
代码示例来源:origin: com.citytechinc.aem.apps.ionic/ionic-aem-apps-core
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);
}
}
代码示例来源:origin: org.apache.sling/org.apache.sling.commons.json
/**
* 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;
}
代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle
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;
}
代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle
@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);
}
代码示例来源:origin: io.wcm/io.wcm.handler.media
/**
* 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;
}
代码示例来源:origin: org.apache.flink/flink-streaming-java_2.10
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");
}
代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle
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;
}
内容来源于网络,如有侵权,请联系作者删除!