yasson

JSON Binding @JsonbTypeDeserializer annotation ignored on enums?

时光怂恿深爱的人放手 提交于 2021-01-28 06:36:28
问题 I'm converting a JAXB application to JSON-B and I've run into an issue while trying to deserialize a Java enum using a custom JsonbDeserializer inside one of my tests. The original JSON I need to deserialize contains int s referencing the enum's constants. Therefore my custom JsonbDeserializer needs to take the int and return the enum constant with the matching ordinal . It looks like this: @JsonbTypeDeserializer(Region.RegionDeserializer.class) public enum Region implements BaseEnum { REGION

Convert JsonObject to pojo efficiently with JSON-B 1.0 (e.g. Yasson, Java EE 8)

旧巷老猫 提交于 2019-12-12 19:33:02
问题 A JsonObject can be transformed into it's corresponding class instance via: Pojo pojo = JsonbBuilder.create().fromJson(jsonObject.toString(), Pojo.class) However, it seems to be inefficient to use jsonObject.toString() as a String is an other intermediate representation, that contains the same information. I need to transform the jsonObject before the object binding. So is there a more efficient way to achieve the binding from a JsonObject? (Note I want to implement with Java EE 8 standards,

Stakover flow error with Jackson applied on JPA Entities to generate JSON

喜欢而已 提交于 2019-12-02 13:51:38
问题 I have a JPA code with OneToMany relationship. A Customer has a list of Item to check out. However, the code continue to generate StackOverflowError . Once, I had resolved this one by applying @JsonIgnore while fetching the List<Item> from Customer entity. But even that does not seem to work anymore. In Customer class: @OneToMany(mappedBy = "customer", orphanRemoval = true) @JsonIgnore private List<Item> items; In Item class: @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "CUSTOMER_ID"

Stakover flow error with Jackson applied on JPA Entities to generate JSON

冷暖自知 提交于 2019-12-02 03:20:06
I have a JPA code with OneToMany relationship. A Customer has a list of Item to check out. However, the code continue to generate StackOverflowError . Once, I had resolved this one by applying @JsonIgnore while fetching the List<Item> from Customer entity. But even that does not seem to work anymore. In Customer class: @OneToMany(mappedBy = "customer", orphanRemoval = true) @JsonIgnore private List<Item> items; In Item class: @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "CUSTOMER_ID", nullable = false) private Customer customer; And CustomerRest class: @Path("customers") public class