本文整理了Java中com.atlassian.jira.util.json.JSONArray.getString()
方法的一些代码示例,展示了JSONArray.getString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONArray.getString()
方法的具体详情如下:
包路径:com.atlassian.jira.util.json.JSONArray
类名称:JSONArray
方法名:getString
[英]Get the string associated with an index.
[中]获取与索引关联的字符串。
代码示例来源:origin: com.atlassian.jira/jira-api
private static Collection<String> getGroups(final JSONArray jsonArray) throws JSONException
{
Set<String> groups = Sets.newHashSetWithExpectedSize(jsonArray.length());
for (int i = 0 ; i<jsonArray.length(); i++)
{
groups.add(jsonArray.getString(i));
}
return groups;
}
代码示例来源:origin: com.atlassian.jira/jira-core
private static List<String> parseShortcut(String shortcut) throws JSONException
{
if (JSON_VALUE_ARRAY.matcher(shortcut).matches())
{
final JSONArray array = new JSONArray(shortcut);
final List<String> result = Lists.newArrayListWithCapacity(array.length());
for (int i = 0; i < array.length(); i++) {
result.add(array.getString(i));
}
return result;
}
else if (JSON_VALUE_STRING.matcher(shortcut).matches())
{
final String key = "shortcut";
JSONObject json = new JSONObject(String.format("{ \"%s\": %s }", key, shortcut));
return Arrays.asList(json.getString(key));
}
else
{
final List<String> result = new ArrayList<String>();
for (char c : shortcut.toCharArray())
{
result.add(String.valueOf(c));
}
return result;
}
}
代码示例来源:origin: com.atlassian.jira/jira-issue-link-remote-jira-plugin
private static ErrorCollection convertResponseToErrorCollection(final JSONObject json, final RestVersion restVersion) throws JSONException
{
final ErrorCollection errors = new SimpleErrorCollection();
switch (restVersion)
{
case VERSION_2_0alpha1:
case VERSION_2:
{
final JSONArray errorMessages = json.getJSONArray("errorMessages");
for (int i = 0; i < errorMessages.length(); i++)
{
errors.addErrorMessage(errorMessages.getString(i));
}
final JSONObject errorsMap = json.getJSONObject("errors");
final Iterator<String> keys = errorsMap.keys();
while (keys.hasNext())
{
final String key = keys.next();
errors.addError(key, errorsMap.getString(key));
}
break;
}
default:
{
throw new UnsupportedOperationException("Unsupported REST version: " + restVersion);
}
}
return errors;
}
代码示例来源:origin: com.atlassian.cpji/cpji-jira-plugin
private static ErrorCollection convertJsonToErrorCollection(final JSONObject json)
{
final ErrorCollection errors = new SimpleErrorCollection();
try
{
final JSONArray errorMessages = json.getJSONArray("errorMessages");
for (int i = 0; i < errorMessages.length(); i++)
{
errors.addErrorMessage(errorMessages.getString(i));
}
final JSONObject errorsMap = json.getJSONObject("errors");
final Iterator<String> keys = errorsMap.keys();
while (keys.hasNext())
{
final String key = keys.next();
errors.addError(key, errorsMap.getString(key));
}
}
catch (final JSONException e)
{
return null;
}
return errors;
}
代码示例来源:origin: com.atlassian.jira/jira-api
/**
* Produce a JSONArray containing the values of the members of this
* JSONObject.
*
* @param names A JSONArray containing a list of key strings. This
* determines the sequence of the values in the result.
* @return A JSONArray of values.
* @throws JSONException If any of the values are non-finite numbers.
*/
public JSONArray toJSONArray(final JSONArray names) throws JSONException
{
if ((names == null) || (names.length() == 0))
{
return null;
}
final JSONArray ja = new JSONArray();
for (int i = 0; i < names.length(); i += 1)
{
ja.put(opt(names.getString(i)));
}
return ja;
}
代码示例来源:origin: com.atlassian.jira/jira-api
/**
* Produce a JSONObject by combining a JSONArray of names with the values
* of this JSONArray.
*
* @param names A JSONArray containing a list of key strings. These will be
* paired with the values.
* @return A JSONObject, or null if there are no names or if this JSONArray
* has no values.
* @throws JSONException If any of the names are null.
*/
public JSONObject toJSONObject(final JSONArray names) throws JSONException
{
if ((names == null) || (names.length() == 0) || (length() == 0))
{
return null;
}
final JSONObject jo = new JSONObject();
for (int i = 0; i < names.length(); i += 1)
{
jo.put(names.getString(i), opt(i));
}
return jo;
}
内容来源于网络,如有侵权,请联系作者删除!