Questions tagged [yasson]

Yasson: https://github.com/eclipse-ee4j/yasson

29 questions
6
votes
1 answer

Deserialize JSON into polymorphic POJO with JSON-B / Yasson

I have a PATCH endpoint in a resource class with an abstract class as a request body. I'm getting the following error: 22:59:30 SEVERE [or.ec.ya.in.Unmarshaller] (on Line: 64) (executor-thread-63) Can't create instance It seems that because the…
spaykit
  • 121
  • 1
  • 8
6
votes
1 answer

Why is javax.json from Glassfish needed as a dependency when using Yasson with JSON-B?

In order to use Java API for JSON Binding (JSON-B), I have found it necessary to include the following three dependencies in my Maven POM:
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
4
votes
1 answer

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

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…
Marc Dzaebel
  • 425
  • 4
  • 12
2
votes
3 answers

How to parse array of numeric values in a JSON to Java object with Jsonb

I love how easy it is to map JSON data to a Java object with Jsonb, but I seem to have stumbled upon a not well-documented use-case... Given this json data: { "id": "test", "points": [ [ -24.787439346313477, 5.5551919937133789 …
Frank
  • 5,741
  • 4
  • 28
  • 49
2
votes
1 answer

Java Jsonb deserializing UTC datetime in ISO8601

I'm using JSON-B (yasson implementation) and I'm receiving data for an object with a field like this { ... "timestamp": "2020-03-19T06:42:42Z", ... } which is perfectly standard ISO 8601 for a UTC date-time value. Now the corresponding Java…
2
votes
1 answer

JSON Binding @JsonbTypeDeserializer annotation ignored on enums?

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 ints referencing the enum's…
Lukáš Petrovický
  • 3,945
  • 1
  • 11
  • 20
2
votes
1 answer

How can I prevent empty strings and empty collections to be outputted with eclipse Yasson

We want to create a json string for some Java objects, but we don't want empty strings or empty arrays to be added to the json output. We are using Eclipse Yasson 1.0.1 to create the json strings. Actually what we want is the behaviour of…
Gert
  • 23
  • 4
1
vote
2 answers

Java 17 module project (maven), when reading Json NoClassDefFoundError: jakarta/json/JsonConfig$KeyStrategy

This is not my first module based project but I am very shakey on how it all works, I am sure this is my issue. Project Jigsaw seems like smoke and mirrors to me at the moment. Any assistance would be greatly appreciated. Here is where the…
Damien Cooke
  • 599
  • 10
  • 20
1
vote
0 answers

Equivalent of Jackson's @JsonUnwrapped in Jsonb

I tried to implement the equivalent of Jacksons's @JsonUnwrapped in Jsonb (using Yasson) with this: @Retention(RetentionPolicy.RUNTIME) @JsonbTypeSerializer(UnwrappedJsonbSerializer.class) public @interface JsonbUnwrapped {} public class…
Xavier Dury
  • 1,530
  • 1
  • 16
  • 23
1
vote
0 answers

Is there a Yasson/Json-b equivalent of JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY

I am converting a library from Jackson to json-b, but I cannot find the equivalent of JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY. Does such a thing exist? I got the following to work, but I hate to use Yasson internals to do so. public static…
1
vote
3 answers

Quarkus JsonB change to different timezone

quarkus jsonb is deserializing json in UTC. How can I configure a different timezone? public class AtendimentoDTO { public Integer id; @JsonbDateFormat("dd/MM/yyyy HH:mm:ss") private Date dataAtualizacao; } Output in…
user4081947
  • 141
  • 1
  • 7
1
vote
1 answer

Is it possible to set the default date format in JSON-B (Yasson) globally, instead of adding an annotation on every property?

I have using Jersey so far and I am doing my first implementation with JSON-B. I am using Payara, so I working with Jersey and Yasson. I had an issue, because the serialized dates would always contain the "[UTC]" suffix. I have managed to use an…
Olivier Liechti
  • 3,138
  • 2
  • 19
  • 26
1
vote
1 answer

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

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 from Customer…
Singam
  • 443
  • 3
  • 12
1
vote
2 answers

How to exclude Weld metadata from JSON object serialization

Assume the following REST resource: @Path("/ActiveLeadTask") //Also possible MediaType.APPLICATION_XML @Produces(MediaType.APPLICATION_JSON) public class ActiveLeadTask { private @Inject ActiveLeadTaskBo activeLeadBo; @GET …
aleksander_si
  • 1,021
  • 10
  • 28
1
vote
1 answer

localdate json binding with yasson implementation in wildfly server

If I use LocalDate type in my entity class I get the following error if I send a POST request: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `java.time.LocalDate` (no Creators, like default construct,…
surfspider
  • 727
  • 3
  • 11
  • 25
1
2