本文整理汇总了Java中net.minidev.json.JSONObject.escape方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.escape方法的具体用法?Java JSONObject.escape怎么用?Java JSONObject.escape使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minidev.json.JSONObject
的用法示例。
在下文中一共展示了JSONObject.escape方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareBugDescriptionForBugCreation
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
/**
* Prepares the description of bug body. By adding build url, a nice header, a note and
* excaptes html tags, json tags.
*
* @param description
* @return
*/
private String prepareBugDescriptionForBugCreation(String description)
{
description = "*[Automation failed tests]*\n" +
"||Testcase failing|| Parameters||\n" +
description + "\n" +
System.getProperty(AUTO_CREATE_ADDITIONAL_DETAILS,
configuration.getProperty(AUTO_CREATE_ADDITIONAL_DETAILS, "")) + "\n" +
"Build url: " + buildUrl;
description = description + "\n\n\n" + "Note: This bug is created automatically by DolphinNG." +
" Please do not edit summary line of the bug.";
description = StringEscapeUtils.escapeHtml3(description);
description = StringEscapeUtils.escapeHtml4(description);
description = JSONObject.escape(description);
return description;
}
示例2: addCommentToIssue
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
/**
* Adds a comment to the jira ticket
*
* @param jiraTicket - jira ticket id
* @param comment - comment to add
* @return
* @throws MalformedURLException
*/
public boolean addCommentToIssue(String jiraTicket, String comment) throws MalformedURLException
{
URL request = new URL("https://" + configuration.getProperty(DEFECT_MGMT_HOST) +
configuration.getProperty(BUG_API) + "/" + jiraTicket + "/comment");
comment = comment + "\n\n\n" + "Test Run URL: " + buildUrl;
comment = comment + "\n" + "Note: This comment is created automatically by DolphinNG.";
comment = StringEscapeUtils.escapeHtml3(comment);
comment = StringEscapeUtils.escapeHtml4(comment);
comment = JSONObject.escape(comment);
String payload =
"{" +
"\"body\":" + "\"" + comment + "\"" +
"}";
RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
RequestSpecification given = RestAssured.given();
given = given.header(authenticationHeader);
Response response = given
.contentType(CONTENT_TYPE_APPLICATION_JSON)
.accept(CONTENT_TYPE_APPLICATION_JSON)
.when().body(payload).post(request).then()
.extract().response();
LOG.info("JIRA ticket creation result---> StatusCode=" +
response.getStatusCode() + " status=" + response.getStatusLine() +
" payload=" + payload +
" Response=" + response.getBody().prettyPrint());
return response.getStatusCode() == 201;
}
示例3: matchText
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
public Match matchText(String exp, MatchType matchType) {
String quoted = exp == null ? "null" : "\"" + JSONObject.escape(exp) + "\"";
return match(quoted, matchType);
}