I use the below libs
- quarkus-hibernate-orm-panache
- quarkus-agroal quarkus-jdbc-mysql
- quarkus-resteasy-jsonb
- quarkus-resteasy
- rest-assured
My @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;
}
My Resources
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Products> getProducts() {
return Products.listAll() ;
}
With "quarkus-resteasy-jackson" I get
[{"id":"0b3d7518","name":"tests org","description":null},{"id":"78787518f","name":"ci tests org 2","description":"some text"}]
vs
With "quarkus-resteasy-jsonb" I get
[{"id":"0b3d7518f3","name":"tests org"},{"description":"some text","id":"78787518f","name":"ci tests org 2"}]
Question ?
If I use, quarkus-resteasy-jackson, it returns null value as a part of response. while quarkus-resteasy-jsonb does not return columns with null value as a part of response. "description" is not there in the response for id:0b3d7518f3. I need all fields. How can I achieve it. ?
Jackson order of json nodes is "id, name, description" the way I ordered in Entity. While JsonB it is "description,id,name". It is using sorted keys. Is there a way to override it in json?
Thanks
Well, I would say you answered the question yourself: if Jackson fits your needs, just use Jackson.
If you really want to use JSON-B, you can configure
JsonbConfig
with aJsonbConfigCustomizer
bean.See https://quarkus.io/guides/rest-json#json-b .
You can require the null values for sure and also tweak the ordering.