我使用以下库
- quarkus-hibernate-orm-华丽
- quarkus-agroal quarkus-jdbc-mysql
- quarkus-resteasy-jsonb
- quarkus-resteasy
- 放心
我的@Entity
public class Products extends PanacheEntityBase implements Serializable{
private static final long serialVersionUID = 2L;
@Id
@Column( name = "id" )
public String id;
public String name;
public String description;
}
我的资源
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Products> getProducts() {
return Products.listAll() ;
}
使用“quarkus-resteasy-jackson”我得到
[{"id":"0b3d7518","name":"tests org","description":null},{"id":"78787518f","name":"ci tests org 2","description":"some text"}]
对比
使用“quarkus-resteasy-jsonb”我得到
[{"id":"0b3d7518f3","name":"tests org"},{"description":"some text","id":"78787518f","name":"ci tests org 2"}]
问题 ?
如果我使用 quarkus-resteasy-jackson,它会返回空值作为响应的一部分。而 quarkus-resteasy-jsonb 不返回具有空值的列作为响应的一部分。id:0b3d7518f3 的响应中没有“描述”。我需要所有领域。我怎样才能实现它。?
json 节点的杰克逊顺序是我在实体中订购的方式“id、name、description”。而 JsonB 它是“描述、ID、名称”。它使用排序键。有没有办法在json中覆盖它?
谢谢