Reputation: 13
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
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