本文整理了Java中com.atlassian.jira.util.json.JSONObject.<init>()
方法的一些代码示例,展示了JSONObject.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.<init>()
方法的具体详情如下:
包路径:com.atlassian.jira.util.json.JSONObject
类名称:JSONObject
方法名:<init>
[英]Construct an empty JSONObject.
[中]构造一个空的JSONObject。
代码示例来源:origin: com.atlassian.jira/jira-core
private JSONObject getObject()
{
if (delegateSupplier.get().isAdminWithoutIssuePermission())
{
return new JSONObject(DATA);
}
else
{
return new JSONObject();
}
}
代码示例来源:origin: com.atlassian.jira/jira-core
private JSONObject getDismissalResets()
{
String dismissalResets = getPropertySet().getText(RESETS_KEY);
try
{
return isBlank(dismissalResets) ? new JSONObject() : new JSONObject(dismissalResets);
}
catch (JSONException e)
{
return new JSONObject();
}
}
代码示例来源:origin: com.atlassian.jira/jira-core
private JSONObject getDismissalsForUser(ApplicationUser user)
{
String dismissals = userPreferencesManager.getExtendedPreferences(user).getText(DISMISSALS_KEY);
try
{
return isBlank(dismissals) ? new JSONObject() : new JSONObject(dismissals);
}
catch (JSONException e)
{
return new JSONObject();
}
}
代码示例来源:origin: com.atlassian.jira/jira-api
@Override
public EntityPropertyBean apply(final Map<String, Object> entityPropertyBean)
{
final String key = (String) entityPropertyBean.get("key");
final Map<String, Object> value = (Map<String, Object>) entityPropertyBean.get("value");
return new EntityPropertyBean(key, new JSONObject(value).toString(), null);
}
}));
代码示例来源: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
public static UserFilter fromJsonString(String jsonString) throws JSONException
{
if (StringUtils.isEmpty(jsonString))
{
return UserFilter.DISABLED;
}
else
{
return UserFilterUtils.fromJson(new JSONObject(jsonString));
}
}
代码示例来源:origin: com.atlassian.plugin.automation/jira-automation-spi
private static JSONObject createJSONEntry(DateTime when, String entry)
{
try
{
return new JSONObject().put("date", when.toString(ISO_DATE_FORMAT)).put("entry", entry);
}
catch (JSONException e)
{
return new JSONObject();
}
}
}
代码示例来源:origin: com.atlassian.jira/jira-api
/**
* Put a key/value pair in the JSONObject, where the value will be a
* JSONObject which is produced from a Map.
*
* @param key A key string.
* @param value A Map value.
* @return this.
* @throws JSONException If the value is non-finite number or if the key is null.
*/
public JSONObject put(final String key, final Map<String, Object> value) throws JSONException
{
put(key, new JSONObject(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 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-core
private JSONObject getDateFormatsJson(final DateFormatSymbols dateFormatSymbols)
{
final ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
builder.put("meridiem", Arrays.asList(dateFormatSymbols.getAmPmStrings()));
builder.put("eras", Arrays.asList(dateFormatSymbols.getEras()));
builder.put("months", Arrays.asList(dateFormatSymbols.getMonths()).subList(0, 12));
builder.put("monthsShort", Arrays.asList(dateFormatSymbols.getShortMonths()).subList(0, 12));
builder.put("weekdaysShort", Arrays.asList(dateFormatSymbols.getShortWeekdays()).subList(1, 8));
builder.put("weekdays", Arrays.asList(dateFormatSymbols.getWeekdays()).subList(1, 8));
return new JSONObject(builder.build());
}
}
代码示例来源:origin: com.atlassian.jira/jira-issue-link-remote-jira-plugin
@Override
public JSONObject convert(final String responseString)
{
try
{
return new JSONObject(new JSONTokener(responseString));
}
catch (JSONException e)
{
throw new RuntimeException("Failed to parse remote JIRA response", e);
}
}
}
代码示例来源:origin: com.atlassian.jira/jira-api
/**
* Create a SharePermission from the passed JSON string.
*
* @param jsonString the JSON string make a SharePermission from.
* @return the new SharePermission.
* @throws JSONException if an error occurs while converting the object.
*/
public static SharePermission fromJsonObjectString(final String jsonString) throws JSONException
{
notNull("jsonString", jsonString);
if (StringUtils.isBlank(jsonString))
{
return null;
}
return SharePermissionUtils.fromJsonObject(new JSONObject(jsonString));
}
代码示例来源:origin: com.atlassian.plugin.deflection/deflection-outages
protected String getPluginStatusKey() throws IOException, JSONException
{
//Will get the plugin status either ENABLE or DISABLE
JSONObject applicationParamStatusObj = new JSONObject(getJSON(PLUGIN_STATUS_KEY_URL));
return applicationParamStatusObj.getString("status");
}
代码示例来源:origin: com.marvelution.jira.plugins/jira-jenkins-plugin
public RestResponse(Response response) {
statusCode = response.getStatusCode();
statusMessage = response.getStatusText();
successful = response.isSuccessful();
try {
responseBody = IOUtils.toString(response.getResponseBodyAsStream(), "UTF-8");
json = new JSONObject(responseBody);
} catch (JSONException e) {
json = null;
errors.add("Failed to parse server response as JSON: " + e.getMessage());
} catch (Throwable e) {
errors.add("Failed to retrieve the response from Jenkins: " + e.getMessage());
}
}
代码示例来源:origin: com.atlassian.plugin.automation/jira-automation-spi
public String getJSONString()
{
try
{
return new JSONObject().put(LAST_KEY, last).put(ALL_KEY, all).toString();
}
catch (JSONException e)
{
return "{}";
}
}
代码示例来源:origin: com.atlassian.jira/jira-core
private void populateJsonWithSetupStatus(final JSONObject json, final AsynchronousJiraSetup.SetupStatus<InstantSetupStrategy.Step> setupStatus)
throws JSONException
{
final JSONObject stepsJson = new JSONObject();
json.put("steps", stepsJson);
for (final InstantSetupStrategy.Step step : setupStatus.getSteps().keySet())
{
stepsJson.put(step.name().toLowerCase(), setupStatus.getSteps().get(step).name().toLowerCase());
}
final String errorMessage = setupStatus.getError();
if (errorMessage != null)
{
json.put("errorMessage", errorMessage);
}
}
代码示例来源: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
public String doSetupFinished() throws IOException, JSONException
{
final JSONObject json = new JSONObject();
if (setupAlready() && AsynchronousJiraSetupFactory.getInstance().isSetupFinished(getSetupSessionId()))
{
json.put("redirectUrl", getRedirectUrl());
json.put("SEN", getSupportEntitlementNumber());
}
else
{
throw new RuntimeException("Setup is not yet finished");
}
writeJSONToHttpResponse(json);
return NONE;
}
代码示例来源:origin: com.atlassian.jira/jira-core
private String getLanguageTextsJsonForLocale(final Locale locale) throws JSONException
{
final I18nHelper i18nHelper = ComponentAccessor.getI18nHelperFactory().getInstance(locale);
final JSONObject json = new JSONObject();
json.put("button", i18nHelper.getText("common.words.save"));
json.put("cancel", i18nHelper.getText("common.forms.cancel"));
json.put("connectionWarningContent", i18nHelper.getText("setup.language.dialog.connection.warning.content"));
json.put("connectionWarningTitle", i18nHelper.getText("setup.language.dialog.connection.warning.title"));
json.put("langLabel", i18nHelper.getText("setup.choose.language"));
json.put("langDesc", i18nHelper.getText("setupdb.server.language.description"));
json.put("header", i18nHelper.getText("setup.language.dialog.header"));
return json.toString();
}
代码示例来源:origin: com.atlassian.jira/jira-core
@ActionViewData
public String getErrorTextsJson() throws JSONException
{
final I18nHelper i18nHelper = ComponentAccessor.getI18nHelperFactory().getInstance(getLocale());
final JSONObject json = new JSONObject();
json.put("invalidEmail", i18nHelper.getText("setup.account.form.email.invalid"));
json.put("emailRequired", i18nHelper.getText("setup.account.form.email.required"));
json.put("invalidCredentials", i18nHelper.getText("setup.account.invalid.credentials"));
json.put("passwordRequired", i18nHelper.getText("setup.account.form.password.required"));
json.put("agreementRequired", i18nHelper.getText("setup.account.form.agreement.required"));
json.put("fullnameRequired", i18nHelper.getText("setup.account.form.fullname.required"));
return json.toString();
}
}
内容来源于网络,如有侵权,请联系作者删除!