-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serialize by reference - used to work with 1.9.11 #539
Comments
One problem I see is this: there is no public accessor, nor |
Another problem is that So I guess what I really need is more complete test case; plus, above comment for missing |
Full executable example:
I can't annotate getTree or tree because it's actually not a json property at all but the cache of the entire json blob which I deserialized before. Before attempting to upgrade to Jackson 2.4, i was on 1.9.11. |
I am sorry but example is big enough that I can't follow on what it is really trying to achieve, or where it goes wrong. I don't understand reference to "just uses empty deserializer": empty bean handling (as special case) only applies to serialization; but even there, custom serializers are checked first. So at this point I don't quite understand what your problem is, or what to do with it. |
I described the original problem in a different ticket: #549 The link on stackoverflow didn't help? |
I can understand the other issue to some degree (although it took quite a bit of time). |
I guess you need to see the code running through the module and why it was built in the first place. With the above code, replace the main function with:
The interest of the module -- I hope you can see it above -- is to get back the full blob with my change when i reserialize Bar. Thing is, even if the POJO is empty, has no properties, for some dumb reason (config issue, dev problem, some bad code clean up), i still want to get back the whole blob (which is cached in JsonContainer). It used to work in 1.9 because no matter what, my Pojo was running through the module regardless of whether it has defined properties. Now, it skips the module which may have special treatment for that type because the pojo has no properties. The module above is a ghetto / quick support for #549 and only works for 1st level properties.
... stoppedWorking() would be equivalent to that line above... but now returns me an empty blob with jackson 2. Is this helping? |
Would it be possible to write a simple reproducible case that only shows the part of skipping module: it need not to actual functionality you have or anything. I just don't see why serializer construction was not working as expected. On the other hand, sub-classing of Another thing I notice in serializer is that it modifies the tree given as input (removing entries). This means that serialization is not idempotent. It would be safer to keep |
Here you go, smallest possible and comparative example:
|
Ok I'll try the code and see if it makes more sense. |
And just to prove i'm not bluffing, here's the version I use with Jackson 1.9.11 ;)
This outputs:
While the version for jackson 2 outputs:
|
Ok, so failure I saw was with "can't serialize POJO with no properties"; and that can be disabled with:
would this help? With this, the code passes. But I guess even without this setting, |
... and indeed, that does not work, somewhat surprisingly. Why surprisingly? Because there's unit test Alas, it only tests So I think I finally see the underlying bug here. :) |
Yeeaeaaaahhh :) |
Unfortunately change is non-trivial, so I think this should only go in 2.5. Work-around with earlier versions is to use:
which will result in expected behavior as well (i.e. Note that with the fix, type of |
Code:
Then i have a jackson module and method (in JsonUtils) that check when an object is an instance of JsonContainer and when it is, it is supposed to serialize and deserialize in a special (deserialization set the tree attribute, serialization uses the module that extends BeanSerializer and overrides serializeFields...
Problem is that with jackson 2 now, when the class doesn't have any attributes, it just uses the unknown deserializer by default... and skips checking whether a bean serializer might be available...
I understand this is a very brief, possibly incomprehensible explanation... The entire thing solution i had to write in jackson 1 is on stackoverflow though:
http://stackoverflow.com/questions/17967531/jackson-api-partially-update-a-string
In short: the whole problem was to deserialize a huge json blob with only a partial knowledge/class representation of its content but still be able to save the entire thing back.
I wish jackson supports that in the first place.
The text was updated successfully, but these errors were encountered: