本文整理了Java中com.atlassian.jira.util.json.JSONArray.get()
方法的一些代码示例,展示了JSONArray.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONArray.get()
方法的具体详情如下:
包路径:com.atlassian.jira.util.json.JSONArray
类名称:JSONArray
方法名:get
[英]Get the object value associated with an index.
[中]获取与索引关联的对象值。
代码示例来源:origin: com.atlassian.jira/jira-api
/**
* Get the long value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
* @return The value.
* @throws JSONException If the key is not found or if the value cannot
* be converted to a number.
*/
public long getLong(final int index) throws JSONException
{
final Object o = get(index);
return o instanceof Number ? ((Number) o).longValue() : (long) getDouble(index);
}
代码示例来源:origin: com.atlassian.jira/jira-api
/**
* Get the string associated with an index.
*
* @param index The index must be between 0 and length() - 1.
* @return A string value.
* @throws JSONException If there is no value for the index.
*/
public String getString(final int index) throws JSONException
{
return get(index).toString();
}
代码示例来源:origin: com.atlassian.jira/jira-api
/**
* Get the JSONArray associated with an index.
*
* @param index The index must be between 0 and length() - 1.
* @return A JSONArray value.
* @throws JSONException If there is no value for the index. or if the
* value is not a JSONArray
*/
public JSONArray getJSONArray(final int index) throws JSONException
{
final Object o = get(index);
if (o instanceof JSONArray)
{
return (JSONArray) o;
}
throw new JSONException("JSONArray[" + index + "] is not a JSONArray.");
}
代码示例来源:origin: com.atlassian.jira/jira-api
/**
* Get the int value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
* @return The value.
* @throws JSONException If the key is not found or if the value cannot
* be converted to a number.
* if the value cannot be converted to a number.
*/
public int getInt(final int index) throws JSONException
{
final Object o = get(index);
return o instanceof Number ? ((Number) o).intValue() : (int) getDouble(index);
}
代码示例来源:origin: com.atlassian.jira/jira-api
/**
* Get the JSONObject associated with an index.
*
* @param index subscript
* @return A JSONObject value.
* @throws JSONException If there is no value for the index or if the
* value is not a JSONObject
*/
public JSONObject getJSONObject(final int index) throws JSONException
{
final Object o = get(index);
if (o instanceof JSONObject)
{
return (JSONObject) o;
}
throw new JSONException("JSONArray[" + index + "] is not a JSONObject.");
}
代码示例来源:origin: com.atlassian.jira/jira-api
/**
* Get the double value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
* @return The value.
* @throws JSONException If the key is not found or if the value cannot
* be converted to a number.
*/
public double getDouble(final int index) throws JSONException
{
final Object o = get(index);
try
{
return o instanceof Number ? ((Number) o).doubleValue() : Double.valueOf((String) o).doubleValue();
}
catch (final Exception e)
{
throw new JSONException("JSONArray[" + index + "] is not a number.");
}
}
代码示例来源:origin: com.atlassian.jira/jira-api
/**
* Get the boolean value associated with an index.
* The string values "true" and "false" are converted to boolean.
*
* @param index The index must be between 0 and length() - 1.
* @return The truth.
* @throws JSONException If there is no value for the index or if the
* value is not convertable to boolean.
*/
public boolean getBoolean(final int index) throws JSONException
{
final Object o = get(index);
if (o.equals(Boolean.FALSE) || ((o instanceof String) && ((String) o).equalsIgnoreCase("false")))
{
return false;
}
else if (o.equals(Boolean.TRUE) || ((o instanceof String) && ((String) o).equalsIgnoreCase("true")))
{
return true;
}
throw new JSONException("JSONArray[" + index + "] is not a Boolean.");
}
代码示例来源:origin: com.atlassian.jirawallboard/atlassian-wallboard-plugin
static public WallboardPluginSettings loadSettings(PluginSettingsFactory pluginSettingsFactory, ApplicationUser user)
{
WallboardPluginSettings settings = new WallboardPluginSettings(pluginSettingsFactory, user);
Object val = pluginSettingsFactory.createGlobalSettings().get(WALLBOARD_KEY + mapNullToBlank(settings.userKey));
if (val == null)
{
settings.isConfigured = false;
return settings;
}
JSONObject jsonRepresentation;
try
{
jsonRepresentation = new JSONObject((String) val);
JSONArray rawDashboardIds = jsonRepresentation.getJSONArray("dashboardIds");
settings.dashboardIds = new ArrayList<>(rawDashboardIds.length());
for (int i = 0; i < rawDashboardIds.length(); i++)
{
settings.dashboardIds.add(i, (String) rawDashboardIds.get(i));
}
settings.setCyclePeriod(jsonRepresentation.getInt(WallboardServlet.CYCLE_PERIOD.getKey()));
settings.setTransitionFx(jsonRepresentation.getString(WallboardServlet.TRANSITION_FX.getKey()));
settings.setRandom(jsonRepresentation.getBoolean(WallboardServlet.RANDOM.getKey()));
}
catch (JSONException e)
{
settings.isConfigured = false;
}
return settings;
}
内容来源于网络,如有侵权,请联系作者删除!