return fieldJson.toString(); // JIRA 5.0 way
}
@Override
public Issue parse(final JSONObject issueJson) throws JSONException {
final BasicIssue basicIssue = basicIssueJsonParser.parse(issueJson);
final Iterable<String> expandos = parseExpandos(issueJson);
final JSONObject jsonFields = issueJson.getJSONObject(FIELDS);
final JSONObject commentsJson = jsonFields.optJSONObject(COMMENT_FIELD.id);
final Collection<Comment> comments = (commentsJson == null) ? Collections.<Comment>emptyList()
: parseArray(commentsJson, new JsonWeakParserForJsonObject<Comment>(commentJsonParser), "comments");
final String summary = getFieldStringValue(issueJson, SUMMARY_FIELD.id);
final String description = getOptionalFieldStringUnisex(issueJson, DESCRIPTION_FIELD.id);
final Collection<Attachment> attachments = parseOptionalArray(issueJson, new JsonWeakParserForJsonObject<Attachment>(attachmentJsonParser), FIELDS, ATTACHMENT_FIELD.id);
final Collection<IssueField> fields = parseFields(issueJson);
final IssueType issueType = issueTypeJsonParser.parse(getFieldUnisex(issueJson, ISSUE_TYPE_FIELD.id));
final DateTime creationDate = JsonParseUtil.parseDateTime(getFieldStringUnisex(issueJson, CREATED_FIELD.id));
final DateTime updateDate = JsonParseUtil.parseDateTime(getFieldStringUnisex(issueJson, UPDATED_FIELD.id));
final String dueDateString = getOptionalFieldStringUnisex(issueJson, DUE_DATE_FIELD.id);
final DateTime dueDate = dueDateString == null ? null : JsonParseUtil.parseDateTimeOrDate(dueDateString);
final BasicPriority priority = getOptionalNestedField(issueJson, PRIORITY_FIELD.id, priorityJsonParser);
final Resolution resolution = getOptionalNestedField(issueJson, RESOLUTION_FIELD.id, resolutionJsonParser);
final User assignee = getOptionalNestedField(issueJson, ASSIGNEE_FIELD.id, userJsonParser);
final User reporter = getOptionalNestedField(issueJson, REPORTER_FIELD.id, userJsonParser);
final BasicProject project = projectJsonParser.parse(getFieldUnisex(issueJson, PROJECT_FIELD.id));
final Collection<IssueLink> issueLinks;
issueLinks = parseOptionalArray(issueJson, new JsonWeakParserForJsonObject<IssueLink>(issueLinkJsonParserV5), FIELDS, LINKS_FIELD.id);
Collection<Subtask> subtasks = parseOptionalArray(issueJson, new JsonWeakParserForJsonObject<Subtask>(subtaskJsonParser), FIELDS, SUBTASKS_FIELD.id);
final BasicVotes votes = getOptionalNestedField(issueJson, VOTES_FIELD.id, votesJsonParser);
final Status status = statusJsonParser.parse(getFieldUnisex(issueJson, STATUS_FIELD.id));
final Collection<Version> fixVersions = parseOptionalArray(issueJson, new JsonWeakParserForJsonObject<Version>(versionJsonParser), FIELDS, FIX_VERSIONS_FIELD.id);
final Collection<Version> affectedVersions = parseOptionalArray(issueJson, new JsonWeakParserForJsonObject<Version>(versionJsonParser), FIELDS, AFFECTS_VERSIONS_FIELD.id);
final Collection<BasicComponent> components = parseOptionalArray(issueJson, new JsonWeakParserForJsonObject<BasicComponent>(basicComponentJsonParser), FIELDS, COMPONENTS_FIELD.id);
final Collection<Worklog> worklogs;
final URI selfUri = basicIssue.getSelf();
final String transitionsUriString;
if (issueJson.has(IssueFieldId.TRANSITIONS_FIELD.id)) {
Object transitionsObj = issueJson.get(IssueFieldId.TRANSITIONS_FIELD.id);
transitionsUriString = (transitionsObj instanceof String) ? (String) transitionsObj : null;
} else {
transitionsUriString = getOptionalFieldStringUnisex(issueJson, IssueFieldId.TRANSITIONS_FIELD.id);
}
final URI transitionsUri = parseTransisionsUri(transitionsUriString, selfUri);
if (JsonParseUtil.getNestedOptionalObject(issueJson, FIELDS, WORKLOG_FIELD.id) != null) {
worklogs = parseOptionalArray(issueJson,
new JsonWeakParserForJsonObject<Worklog>(new WorklogJsonParserV5(selfUri)),
FIELDS, WORKLOG_FIELD.id, WORKLOGS_FIELD.id);
} else {
worklogs = Collections.emptyList();
}
final BasicWatchers watchers = getOptionalNestedField(issueJson, WATCHER_FIELD.id, watchersJsonParser);
final TimeTracking timeTracking = getOptionalNestedField(issueJson, TIMETRACKING_FIELD.id, new TimeTrackingJsonParserV5());
final Set<String> labels = Sets
.newHashSet(parseOptionalArrayNotNullable(issueJson, jsonWeakParserForString, FIELDS, LABELS_FIELD.id));
final Collection<ChangelogGroup> changelog = parseOptionalArray(
issueJson, new JsonWeakParserForJsonObject<ChangelogGroup>(changelogJsonParser), "changelog", "histories");
final Operations operations = parseOptionalJsonObject(issueJson, "operations", operationsJsonParser);
return new Issue(summary, selfUri, basicIssue.getKey(), basicIssue.getId(), project, issueType, status,
description, priority, resolution, attachments, reporter, assignee, creationDate, updateDate,
dueDate, affectedVersions, fixVersions, components, timeTracking, fields, comments,
transitionsUri, issueLinks,
votes, worklogs, watchers, expandos, subtasks, changelog, operations, labels);
}