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 class ResultDeserializer implements JsonbDeserializer<List<Result>>
{
public ResultDeserializer()
{
}
@Override
public List<Result> deserialize(JsonParser parser, DeserializationContext ctx, Type rtType)
{
// I have to use internals as there are no other ways to get this data
if (((UserDeserializerParser) parser).getCurrentLevel().getLastEvent() == JsonParser.Event.START_ARRAY) {
return ctx.deserialize(rtType, parser);
} else
return List.of(ctx.deserialize(Result.class, parser));
}
}