【发布时间】:2021-01-12 17:53:06
【问题描述】:
我正在尝试获取 jira 板上一些问题的列表。我正在尝试扩展 spring 网站上的教程项目。到目前为止,我可以从单个问题中获取 id 和 key,因为它们是普通对象。但我无法获得所有当前问题的列表。
{
expand: "schema,names"
startAt: 0
maxResults: 50
total: 250
issues: [
{
expand: "operations,versionedRepr…hangelog,renderedFields"
id: "36384"
key: "PE-1327"
fields: {…}
},
{
expand: "operations,versionedRepr…hangelog,renderedFields"
id: "32853"
key: "PE-775"
fields: {…}
},
{
expand: "operations,versionedRepr…hangelog,renderedFields"
id: "32855"
key: "PE-777"
fields: {…}
}
]
}
我的主要课程的片段:
@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.basicAuthentication(auth,auth2).build();
}
@Bean
public CommandLineRunner run(RestTemplate restTemplate) throws Exception {
return args -> {
ValueList response = restTemplate.getForObject(
"https://jiraURL/rest/agile/1.0/board/67/issue",
ValueList.class);
List<Value> valueData = response.getValueList();
log.info(valueData.toString());
};
}
“问题”内数据的 My Value Pojo
@JsonIgnoreProperties(ignoreUnknown = true)
public class Value {
private Long id;
private String key;
public Value() {
}
public Long getId() {
return this.id;
}
public String getKey() {
return this.key;
}
public void setId(Long id) {
this.id = id;
}
public void setKey(String quote) {
this.key = quote;
}
@Override
public String toString() {
return "issues{" +
"id=" + id +
", key='" + key + '\'' +
'}';
}
}
我的 ValueList 类
public class ValueList {
private List<Value> valueList;
//getter and setter
我得到的输出只是
[]
【问题讨论】:
-
https://jiraURL/rest/agile/1.0/board/67/issu是返回您发布的第一个 JSON 还是返回一个数组? -
Json i postet 是一个数组,对吗?因为它以 { 开头,还是我理解错了?
-
{...}是 json 对象。[...]是 json 数组。 -
@Zabuzard 你说得对,我编辑了 json 以使其看起来更精确,就像我在“Talend API Tester”中显示的那样。
标签: java json spring list jira