jsonb-api

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

How to deserialize an interface with json-b?

夙愿已清 提交于 2019-12-22 06:49:11
问题 I'm adapting this Jackson code: @JsonDeserialize(as = EntityImpl.class) public interface Entity { ... } The original code works well, even for nested Entity objects. How to do the same with the new json-b specification? I tried using @JsonbTypeDeserializer but Is that really the way to go? It seems to lack the simplicity of just specifying a class. It doesn't seem to work with nested entities, which is my biggest problem: javax.json.bind.JsonbException: Can't infer a type for unmarshalling

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,

How to deserialize an interface with json-b?

限于喜欢 提交于 2019-12-05 18:09:12
I'm adapting this Jackson code: @JsonDeserialize(as = EntityImpl.class) public interface Entity { ... } The original code works well, even for nested Entity objects. How to do the same with the new json-b specification? I tried using @JsonbTypeDeserializer but Is that really the way to go? It seems to lack the simplicity of just specifying a class. It doesn't seem to work with nested entities, which is my biggest problem: javax.json.bind.JsonbException: Can't infer a type for unmarshalling into: Entity The annotation is not picked up on Entity. I have to add manually with JsonbConfig: