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