JIRA에서 전체 이슈 정보를 JSON 객체로 사용하여 Confluence에서 인쇄하는 매크로가 있습니다. 그러나 Confluence에서는 새로운 라인이 사라지고 포맷팅은 지옥으로 빠져 든다.새 라인 기호 삭제 ( r n)
이 락스의 텍스트 (그리고 그것은 어떻게 보이는지) :
보고서는 이후 비바 리스크 관리 팀에 FTP를 통해 전송됩니다.
Aviva 위험 팀은 일일 보고서를 사용하여 숫자 중 일부를 추출하고 포트폴리오의 위험 성과에 대한 보고서를 제공합니다.
이는 JSON의 모습입니다 :
보고서는 이후 비바 리스크 관리 팀에 FTP를 통해 전송되는 \ 연구 \ n \ r에 \의 nAviva 위험 팀이 추출하기 위해 일일 보고서를 사용합니다. 일부는 이고 포트폴리오의 위험 성과에 대한 보고서는 해당 수치입니다.
는 그리고이 나중에 인쇄됩니다 것입니다 :
보고서는 이후 비바 리스크 관리 팀에 FTP를 통해 전송됩니다. Aviva 위험 팀은 일일 보고서를 사용하여 숫자 의 일부를 추출하고 포트폴리오의 위험 성과에 대한 보고서를 제공합니다.
기본적으로, 이것으로부터 얻을 수있는 것은 \n\r
심볼이 손실되거나 Confluence에서해야 할 방식을 번역하지 않는다는 것입니다. 어떻게 해결할 수 있습니까?
편집 : @Octopus 다음은 코드입니다.
public class FieldinfoMacro implements Macro {
@Override
@SuppressWarnings("unchecked")
// This macro gets the issue's field values from the page's context so you don't have to
// make new requests to Jira for each field seperately
public String execute(Map<String, String> par, String s, ConversionContext conversionContext)
throws MacroExecutionException {
// parameters
String add = (String) par.get("getfield").toLowerCase();
HashMap<String, String> fieldMap = (HashMap<String, String>) conversionContext.getProperty("fieldMap");
JSONObject issue = (JSONObject) conversionContext.getProperty("issueJson");
Object output = null;
Object result = null;
StringBuilder temp = new StringBuilder();
/* if (add.equals("reporter") || add.equals("assignee") || add.equals("account manager")) {
try {
output = issue.getJSONObject("fields").get(fieldMap.get(add));
result = ((JSONObject) output).get("emailAddress");
result = ((String) result).replaceAll("@.*", "");
result = ((String) result).replaceAll("\\W", " ");
} catch (JSONException je) {
je.printStackTrace();
}
} else { */
// get the requested field value from the issue
// there's a handler for the different types of returned data
// i.e. JSONObject, JSONArray, String
try {
output = issue.getJSONObject("fields").get(fieldMap.get(add));
// String handler
if (output instanceof String) {
result = output;
// JSONArray handler (covered different cases)
} else if (output instanceof JSONArray) {
for (int i = 0; i < ((JSONArray) output).length(); i++) {
if (((JSONArray) output).get(i) instanceof JSONObject) {
result = ((JSONArray) output).getJSONObject(i).getString("value");
} else {
if (((JSONArray) output).length() < 2) {
temp.append(((JSONArray) output).getString(i));
} else if (i < ((JSONArray) output).length() - 1) {
temp.append(((JSONArray) output).getString(i) + ", ");
} else temp.append(((JSONArray) output).getString(i));
result = temp;
}
}
// JSONObject handler
} else if (output instanceof JSONObject) {
result = ((JSONObject) output).getString("value");
}
} catch (JSONException je) {
je.printStackTrace();
}
return result.toString();
}
[JSON은 다중 행을 저장할 수 없습니다.] (http://gun.io/blog/multi-line-strings-in-json/) JSON으로 인코딩 된 양식은 나를 놀라게하지 않습니다."무엇이 인쇄되는지"는 인쇄 프로세서가 줄 바꿈을 제대로 처리 할 수 없음으로 인해 발생하는 것 같습니다. – fvu