Hi everyone!

I need to use serialization with type information. Serialization works 
fine, but deserialization fails with:
om.fasterxml.jackson.databind.exc.MismatchedInputException: Unexpected 
token (VALUE_NUMBER_INT), expected START_ARRAY: need JSON Array to contain 
As.WRAPPER_ARRAY type information for class java.lang.Long
 at [Source: 
(String)"["deserialization.fail.example.UserPair",{"user1":["deserialization.fail.example.User",{"id":["java.lang.Long",42],"login":"aaa"}],"user2":42}]";
 
line: 1, column: 140] (through reference chain: 
deserialization.fail.example.UserPair["user2"])

You can see my code in my test repository: 
https://github.com/alex-t0/deserialization-fail-example.git.

Please see this classes:

   1. User - 
   
https://github.com/alex-t0/deserialization-fail-example/blob/master/src/main/java/deserialization/fail/example/User.java
   2. UserPair - 
   
https://github.com/alex-t0/deserialization-fail-example/blob/master/src/main/java/deserialization/fail/example/UserPair.java
   3. MapperUtil - 
   
https://github.com/alex-t0/deserialization-fail-example/blob/master/src/main/java/deserialization/fail/example/MapperUtil.java
   4. UserSerializationTest - 
   
https://github.com/alex-t0/deserialization-fail-example/blob/master/src/test/java/deserialization/fail/example/UserSerializationTest.java

UserPair - is simple class with 2 refs to user. In test I create one user, 
and set it to both references in UserPair. Then serialize UserPair, it 
returns String that seems good:

[
    "deserialization.fail.example.UserPair",
    {
        "user1": [
            "deserialization.fail.example.User",
            {
                "id": [
                    "java.lang.Long",
                    42
                ],
                "login": "aaa"
            }
        ],
        "user2": 42
    }
]

But when deserialing i get exception thar I write before. And it occurs 
when reding user2 by id.

It is my improper use or bug? Is there workaround or proper solution?

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jackson-user/480c3230-8828-4495-9259-da5c6521ca30%40googlegroups.com.

Reply via email to