【问题标题】:Object missing in json object structure response in jersey球衣中json对象结构响应中缺少对象
【发布时间】:2017-07-03 08:27:27
【问题描述】:

这是我的简化对象结构:

@xmlRootelement

ArticleList implements Serializable{

   //ArrayList of articles

}

Article implements Serializable
{

  User user;

  //ArrayList of bids

}

User implements Serializable
{

 //Properties

}


Bid implements Serializable
{

 //Properties


}

函数标题:

@GET
@Path("/article-search")
@Produces( MediaType.APPLICATION_JSON )
public ArticleList articleSearch() {

    //Function code here

}

我在 jersey 函数中返回 ArticleList。在答案中,我检查是否存在带有元素的对象出价。

问题是在响应中找不到对象Bids的任何元素

响应示例:

{

    "articles":[
        {
            //Some Props. Here
            "user":{
                 //Some Props. Here
            }
            //Here list of bids is missing. It is verified that the list contains elements
        }
    ]

}

【问题讨论】:

    标签: java json serialization jersey-2.0


    【解决方案1】:

    我需要在对象 Article 中添加 Bid 数组列表的 getter 和 setter

    【讨论】:

      猜你喜欢
      • 2013-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-21
      • 2022-01-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多