Divya
Divya

Reputation: 13

how to get the value of an object in java which is used for attlassian jira

I have getIssue() method in jira that returns a HashMap as output. I want the value held in the affectsVersions object as output. But I am getting an exception. getIssue() is an rpc-xml method

HashMap<String,String> result = (HashMap<String,String>) rpcClient.execute("jira1.getIssue", issueVector);
String ver = (String) result.get("affectsVersions");
System.out.println(ver);

Output:

Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.lang.String

Upvotes: 1

Views: 39

Answers (1)

Scott Dudley
Scott Dudley

Reputation: 3298

The affectsVersions field is returning an array of objects, not a single String (since an issue can have multiple Affects Versions).

In line 2, you want to write:

Object[] affectsVersions = (Object[])result.get("affectsVersions");

...and then iterate through the array as needed.

Upvotes: 1

Related Questions