O
O
Oleg Mikhailov2018-09-19 15:48:25
Java
Oleg Mikhailov, 2018-09-19 15:48:25

How to deserialize an object in Redisson Codec?

Writing to the database is implemented through Redisson. All of these are labeled as follows:

user.class
public class User implements Serializable {

    private static final long serialVersionUID = -960024560523175889L;
    @JsonProperty("1")
    public String id;
    @JsonProperty("2")
    public long lastRequest = 0L;
    @JsonProperty("3")
    public String lastRequestDate = "";
    //    public long lastCookieMatching = 0L;
    @JsonProperty("4")
    public HashMap<String, Long> cookieMatchingTimes = new HashMap<>();
    @JsonProperty("5")
    private boolean needToSave = false;
    @JsonProperty("6")
    private HashMap<String, Integer> dailyActions = new HashMap<>();

The database is in this form:
1) "\"ud_81c277fbc5f228ee221576e0558d6ffe\""
2) "\x00\x00\x00\x00\x00\x00\x00\x00\xb3\x00\x00\x00\x00\x00\x00\ x00{\"@class\":\" delivery.containers.User \",\"1\":\"81c277fbc5f228ee221576e0558d6ffe\",\"2\":0,\"3\":\"2018-09 -19\",\"4\":{\"@class\":\"java.util.HashMap\"},\"5\":false,\"6\":{\"@class\ ":\"java.util.HashMap\"}}"
The problem is that now if I run the second version of the project where the package for User has moved, I can't deserialize it anymore. Error:
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Unexpected token (END_OBJECT),
Codec for Redisson config I use - MsgPackJacksonCodec.
I also tried to mark a class like this, but the result did not work at all:
@JsonTypeInfo(use = Id.MINIMAL_CLASS,  include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonSubTypes.Type(value = User.class, name = ".User")
public class User implements Serializable {

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question