-
-
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
Partial deserialization with POJOs, but requires full reserialization #549
Comments
I am not sure what exactly is asked here. Tests pass as expected; partial update is supported. One thing that could help is use of "any-setters"/"any-getters". They are explained in http://www.cowtowncoder.com/blog/archives/2011/07/entry_458.html (for example), and allow you to keep track of additional extra properties. But in most cases if you want to work with unknown content, JSON Tree ( |
Well, no, in the second case, i want to have: I don't see why i could not update a json (string) with a partial POJO representation of the full blob... |
I do not understand how it would ever become 'OK' case here: Jackson never modifies JSON Strings, ever. It can construct POJOs from JSON input; and create JSON output from POJOs. In this case class To support something similar, you would do well to read the link I pointed you to. It allows you to construct POJOs to return arbitrary set of additional values. |
It could if I could write something like:
This is not a bug ticket. It's a "desired feature" ticket ;) |
Ah. Ok, this makes sense. I think there may already be an issue filed for supporting what is basically a "merge". But it may be that it'd be easier to have code merging two Idea of using a Thank you for explaining this; this sounds like an interesting feature to add. |
And somehow (probably with a proxy), I'd like to have an annotation to deal nicely with this and never see a JsonNode...
|
I don't think this is possible, since while annotations can indicate presence of extra storage, POJO type itself does not have any. So even if code knew it was to keep track of additional data as metadata, there's no place to stash it in. |
Well, Jackson creates the POJO's instances, so when it meets that annotation, it could create a proxy instead and cache the tree in the invocation handler. |
While I am not sure if it'd be technically doable (perhaps it is), I don't see working on adding such a complex feature in core databind. But if there is enough demand, and someone willing to work on making it happen, it could well be an add-on module or such. In the meantime, I really think that the explicit way of using any-getter/any-setter is the way to go, if(f) you can modify original container type. |
I think that #1399, ability to do more actual deep merging should work here. |
Hi,
I have a JSON blob I have no idea what its content that might be. It comes from some database and other scripts may change (delete, create, update) lots of keys/objects/arrays at any depth any time.
However, my java job still needs to read that huge and mysterious blob and update a fragment of it.
Problem is that i'd still like to do that with POJOs. But if I use POJOs, data gets loss while converting to the POJO.
Hereafter is a full executable example:
Note: JSON_INPUT is extremely simplified and there are no patterns of any kind in the real blobs.
Questions:
I basically need the complementary feature of readerForUpdating, where i would update a bigger json blob with a smaller pojo.
The text was updated successfully, but these errors were encountered: