com.atlassian.jira.util.json.JSONArray.put()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(223)

本文整理了Java中com.atlassian.jira.util.json.JSONArray.put()方法的一些代码示例,展示了JSONArray.put()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONArray.put()方法的具体详情如下:
包路径:com.atlassian.jira.util.json.JSONArray
类名称:JSONArray
方法名:put

JSONArray.put介绍

[英]Append a double value. This increases the array's length by one.
[中]附加一个双精度值。这将使阵列的长度增加1。

代码示例

代码示例来源:origin: com.atlassian.jira/jira-api

/**
 * Append a boolean value. This increases the array's length by one.
 *
 * @param value A boolean value.
 * @return this.
 */
public JSONArray put(final boolean value)
{
  put(value ? Boolean.TRUE : Boolean.FALSE);
  return this;
}

代码示例来源:origin: com.atlassian.jira/jira-api

/**
 * 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(final int index, final boolean value) throws JSONException
{
  put(index, value ? Boolean.TRUE : Boolean.FALSE);
  return this;
}

代码示例来源:origin: com.atlassian.jira/jira-api

/**
 * Append an int value. This increases the array's length by one.
 *
 * @param value An int value.
 * @return this.
 */
public JSONArray put(final int value)
{
  put(new Integer(value));
  return this;
}

代码示例来源:origin: com.atlassian.jira/jira-api

/**
 * Append an long value. This increases the array's length by one.
 *
 * @param value A long value.
 * @return this.
 */
public JSONArray put(final long value)
{
  put(new Long(value));
  return this;
}

代码示例来源:origin: com.atlassian.jira/jira-api

/**
 * 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(final int index, final long value) throws JSONException
{
  put(index, new Long(value));
  return this;
}

代码示例来源:origin: com.atlassian.jira/jira-api

/**
 * 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(final int index, final int value) throws JSONException
{
  put(index, new Integer(value));
  return this;
}

代码示例来源:origin: com.atlassian.jira/jira-api

/**
 * 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(final int index, final double value) throws JSONException
{
  put(index, new Double(value));
  return this;
}

代码示例来源:origin: com.atlassian.jira/jira-api

/**
 * 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(final Map<String, Object> value)
{
  put(new JSONObject(value));
  return this;
}

代码示例来源:origin: com.atlassian.jira/jira-api

/**
 * 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<Object> value)
{
  put(new JSONArray(value));
  return this;
}

代码示例来源:origin: com.atlassian.jira/jira-api

/**
 * Append a double value. This increases the array's length by one.
 *
 * @param value A double value.
 * @return this.
 * @throws JSONException if the value is not finite.
 */
public JSONArray put(final double value) throws JSONException
{
  final Double d = new Double(value);
  JSONObject.testValidity(d);
  put(d);
  return this;
}

代码示例来源:origin: com.atlassian.jira/jira-api

/**
 * 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(final int index, final Map<String, Object> value) throws JSONException
{
  put(index, new JSONObject(value));
  return this;
}

代码示例来源:origin: com.atlassian.jira/jira-api

/**
 * 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<? extends Object> value) throws JSONException
{
  put(index, new JSONArray(value));
  return this;
}

代码示例来源:origin: com.atlassian.jira/jira-api

/**
 * Construct a JSONArray from an array
 *
 * @param array array
 * @throws JSONException If not an array.
 */
public JSONArray(final Object array) throws JSONException
{
  this();
  if (array.getClass().isArray())
  {
    final int length = Array.getLength(array);
    for (int i = 0; i < length; i += 1)
    {
      this.put(Array.get(array, i));
    }
  }
  else
  {
    throw new JSONException("JSONArray initial value should be a string or collection or array.");
  }
}

代码示例来源:origin: com.atlassian.plugin.automation/jira-automation-spi

public JiraEntityLogEntry(DateTime timestamp, String entry, String existingEntry)
{
  this.timestamp = timestamp;
  this.entry = entry;
  this.last = createJSONEntry(timestamp, entry);
  final JSONArray jsonArray = new JSONArray();
  jsonArray.put(this.last);
  this.all = StringUtils.isBlank(existingEntry) ? jsonArray : parseExistingArray(existingEntry);
}

代码示例来源:origin: com.atlassian.jira/jira-core

public String getJqlReservedWordsJson() throws JSONException
{
  final Set<String> reservedWords = jqlStringSupport.getJqlReservedWords();
  JSONArray results = new JSONArray();
  for (String reservedWord : reservedWords)
  {
    results.put(reservedWord);
  }
  return results.toString();
}

代码示例来源:origin: com.atlassian.jira/jira-api

/**
 * 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()
{
  final JSONArray ja = new JSONArray();
  for (final String key : keySet())
  {
    ja.put(key);
  }
  return ja.length() == 0 ? null : ja;
}

代码示例来源:origin: com.atlassian.jira/jira-api

/**
 * Converts the passed SharePermissions into a JSON array.
 * 
 * @param permissions the permissions to convert.
 * @return the JSON array.
 * @throws JSONException if an error occurs while creating the JSONArray.
 */
public static JSONArray toJsonArray(final Collection<SharePermission> permissions) throws JSONException
{
  notNull("permission", permissions);
  final JSONArray array = new JSONArray();
  for (final SharePermission sharePermission : permissions)
  {
    array.put(SharePermissionUtils.toJson(sharePermission));
  }
  return array;
}

代码示例来源:origin: com.atlassian.plugin.automation/jira-automation-spi

private JSONArray parseExistingArray(final String existingJson)
{
  JSONArray jsonArray = new JSONArray();
  try
  {
    jsonArray = new JSONObject(existingJson).optJSONArray(ALL_KEY);
  }
  catch (JSONException e)
  {
    // swallow the exception
  }
  jsonArray.put(createJSONEntry(timestamp, entry));
  return jsonArray;
}

代码示例来源:origin: com.atlassian.jira/jira-core

/**
 * Returns a json string of [ {name: groupName}, ... ]
 */
private String getGroupsAsJsonString(final Collection<Group> groups)
{
  JSONArray root = new JSONArray();
  for (Group group : groups)
  {
    JSONObject groupJson = new JSONObject();
    try
    {
      groupJson.put("name", group.getName());
    }
    catch (JSONException e)
    {
      log.warn("skipping project role object that could not converted to json: " + group.getName() + " - " + e.getMessage());
    }
    root.put(groupJson);
  }
  return root.toString();
}

代码示例来源:origin: com.atlassian.jirawallboard/atlassian-wallboard-plugin

public void saveChanges()
{
  JSONObject object = new JSONObject();
  JSONArray array = new JSONArray();
  for (String s : dashboardIds)
  {
    array.put(s);
  }
  try
  {
    object.put("dashboardIds", array);
    object.put(WallboardServlet.CYCLE_PERIOD.getKey(), getCyclePeriod());
    object.put(WallboardServlet.RANDOM.getKey(), isRandom());
    object.put(WallboardServlet.TRANSITION_FX.getKey(), getTransitionFx());
  }
  catch (JSONException e)
  {
    log.log(Level.ERROR, "JSONException in saving changes to wallboard plugin settings:" + e.getMessage());
  }
  pluginSettingsFactory.createGlobalSettings().put(WALLBOARD_KEY + mapNullToBlank(userKey), object.toString());
  isConfigured = true;
}

相关文章