2

I am using kotlin with redisson and jsonjackson as the serializer. Previously when I used jackson in java, it would automatically add a '@class' tag to the json so when I came to deserialize it, it would work fine and redisson would know what class to use. Now it no longer does this and when I try to get something out of an RMap<UUID, UserProfile> (UserProfile is an interface", it gives an error which says "jacksonjson missing type id property '@class'" which is obvisouly due to the json missing the '@class' tag.

Anyone know how I can fix this and have jackson automatically add the @class tag like it previously did? Thank you

  • ""@class": "net.superiormc.user.UserProfileProvider"" this is the tag I am missing, Jackson used to add this automatically but no longer does. – Simon Mitchell Nov 29 '21 at 23:59

2 Answers2

1

Fixed this by adding @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS) to the implementation class

0

If you don't want to annotate classes, it can be configured globally

var codec = new org.redisson.codec.JsonJacksonCodec(new ObjectMapper()
    .enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.NON_FINAL, "@class"));

var config = new org.redisson.config.Config()
    .setCodec(codec);
Sergey Gornostaev
  • 7,596
  • 3
  • 27
  • 39