Jira-Rest-Java-Api:在转换为JSCON时,如何在没有二阶段方法的情况下参考POJO变量
JIRA JQL搜索查询:带终点的帖子方法http:// localhost:8080/rest/api/2/
body:
{
"jql":"project = QA and key=123",
"startAt":0,
"maxResults":1,
"fields":[
"id",
"key",
"custom_Field1"
]
}
上面的结构搜索结构为postman exudy的字段数组的预期值提供了预期值
: < < /em>
REST API JAVA实现
为上述结构POJO类定义,并且在POJO类创建JSCON时,POJO类的变量被忽略了,因为它们不是通过setter方法设置的。因此,从响应中无法获得所需的输出。如何根据上述结构将POJO类转换为JSCON。
从POJO类转换为JSCON
{
"jql":"project = QA and key=123",
"startAt":0,
"maxResults":1,
"fields":[]
}
使用此结构,它在Java Rest rest API POJO类中的custom_field1返回了
如下
public root{
private String jql;
private int startAt;
private int maxResults;
private List<field> fields;
public void setjql(String jql){
this.jql=jql;
}
public String getjql(){
return this.jql;
}
public void setstartAt(int startAt){
this.startAt=startAt;
}
public int getstartAt(){
return this.startAt;
}
public void setmaxResults(int maxResults){
this.maxResults=maxResults;
}
public int getmaxResults(){
return this.maxResults;
}
public void setfields(List<field> fields){
this.fields=fields;
}
public List<fields> getfileds(){
return this.fields;
}
}
public field{
private int id;
private String key;
private String custom_Field1;
public void setID(int id){
this.id=id;
}
public int getID(){
return this.id;
}
public void setKey(String key){
this.key=key;
}
public String getKey(){
return this.key;
}
public void setcustom_Field1(String custom_Field1){
this.custom_Field1=custom_Field1;
}
public String getcustom_Field1(){
return this.custom_Field1;
}
}
JIRA JQL Search Query: post method with end point http://localhost:8080/rest/api/2/search
body:
{
"jql":"project = QA and key=123",
"startAt":0,
"maxResults":1,
"fields":[
"id",
"key",
"custom_Field1"
]
}
above structure giving expected values for variables from fields array in postman
ISSUE :
REST API JAVA IMPLEMENTATION
For above structure POJO class been defined and while creating JSCON from POJO Class, variables from fields POJO class are ignored as they are not set by setter method. Due to this not getting desired output from response. How to convert POJO class to JSCON as per above structure.
Converted JSCON from POJO CLASS
{
"jql":"project = QA and key=123",
"startAt":0,
"maxResults":1,
"fields":[]
}
with this structure it is not returning value for custom_Field1
in Java Rest API POJO Class created as below
public root{
private String jql;
private int startAt;
private int maxResults;
private List<field> fields;
public void setjql(String jql){
this.jql=jql;
}
public String getjql(){
return this.jql;
}
public void setstartAt(int startAt){
this.startAt=startAt;
}
public int getstartAt(){
return this.startAt;
}
public void setmaxResults(int maxResults){
this.maxResults=maxResults;
}
public int getmaxResults(){
return this.maxResults;
}
public void setfields(List<field> fields){
this.fields=fields;
}
public List<fields> getfileds(){
return this.fields;
}
}
public field{
private int id;
private String key;
private String custom_Field1;
public void setID(int id){
this.id=id;
}
public int getID(){
return this.id;
}
public void setKey(String key){
this.key=key;
}
public String getKey(){
return this.key;
}
public void setcustom_Field1(String custom_Field1){
this.custom_Field1=custom_Field1;
}
public String getcustom_Field1(){
return this.custom_Field1;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论