我在 jira 中有 getIssue()
方法,它返回一个 HashMap 作为输出。我希望将 affectsVersions
对象中保存的值作为输出。但我遇到了异常(exception)。 getIssue()
是一个 rpc-xml 方法
HashMap<String,String> result = (HashMap<String,String>) rpcClient.execute("jira1.getIssue", issueVector);
String ver = (String) result.get("affectsVersions");
System.out.println(ver);
输出:
Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.lang.String
最佳答案
affectsVersions 字段返回一个对象数组,而不是单个字符串(因为一个问题可能有多个 Affects 版本)。
在第 2 行中,您要写入:
Object[] affectsVersions = (Object[])result.get("affectsVersions");
...然后根据需要迭代数组。
关于java - 如何获取java中用于atlassian jira的对象的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37206033/