Reputation: 1092
How can i convert jira json string to java object i want to get the issue details
{
"expand": "schema,names",
"startAt": 0,
"maxResults": 50,
"total": 1,
"issues": [
{
"expand": "editmeta,renderedFields,transitions,changelog,operations",
"id": "10000",
"self": "http://jira.com/rest/api/2/issue/10000",
"key": "APPANLYTIX-1",
"fields": {},
"issuetype": {},
"votes": {},
"resolution": null,
"fixVersions": [{}],
"resolutiondate": null,
"timespent": null,
"reporter": {
"avatarUrls": {},
"displayName": "yyyy Dev",
"active": true
},
"subtasks": [],
"status": {},
"labels": [],
"workratio": 0,
"assignee": {
"avatarUrls": {},
"displayName": "",
"active": true
},
"project": {
"name": "",
"avatarUrls": { }
},
"versions": [{}],
"environment": "windows",
"timeestimate": 28800,
"aggregateprogress": {},
"lastViewed": "2013-07-18T04:39:52.596+0000",
"components": [ ],
"timeoriginalestimate": 28800,
"aggregatetimespent": null
}
]
}
Most of the examples I refereed are using java bean for setting the variables,is there any API for doing this?
Upvotes: 1
Views: 1345
Reputation: 133
I handle this problem another third party library, you can download this code. And Edit as your scenario.
You should only edit SimpleConfigurationProvider this java class. You have to specify your privateKey, AccessToken and baseUrl. And then jiraClient Authentication you can receive project and issue thanks to under code block
As a result you can convert java class object as ArrayList and JiraProject[]
https://github.com/symphonyoss/bot-jira
public static void main(String[] args) {
// TODO Auto-generated method stub
JiraOauthClient jiraClient = new JiraOauthClient(new SimpleConfigurationProvider());
JiraProject[] projects = jiraClient.getAllProjects();
for (JiraProject project : projects) {
if (project.getKey().equals("UOCM")) {
ArrayList<JiraIssue> issues = jiraClient.getIssuesForProject(project);
for (JiraIssue issue : issues) {
System.out.println(issue.getId());
///.....
}
}
}
}
Upvotes: 1