-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Pointer based add and remove methods for #392 #393
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
Conversation
Hmm. Aside from the question of where to expose these methods (which in themselves make sense), it seems like these methods would not indicate a failure, when there is no matching path? |
Oh also, definitely need unit tests to show that it works: I am not quite sure about correct matching for exact nodes. Wrt return value, it should work ok with remove method; but I think |
Yeah, sorry, this was more just some initial spit balling: I wasn't sure if the changes to I was thinking of maybe a I was thinking an error is better then creating missing path nodes: a higher level implementation could then choose to fail (that is what the JSON Patch spec says) or handle the error by creating the necessary path. Let me try flushing it out a little; but in general, is the "add or remove by pointer" a worth while addition? |
@jgustie First of all: yes, I think add or remove by pointer definitely makes sense. I have hoped that addition of JSON pointer would spur interest in additions like you suggest. So I am excited about this. I am not entirely sure about But one thing that would probably be good here would be to maybe suggest this on Jackson dev list; I think there is interest in this work. And there are some aspects that have been discussed earlier; especailly the question of whether and how to work on multiple pluggable tree models. I have grown to realize that it is very difficult to come up with a single tree representation that works well for everyone and has intuitive API. One example is issue of mutability: immutable tree models (that is, something where changes are not done by modifying state of existing nodes, but by creating and returning new intances -- i.e. nodes immutable does not mean one can not create modified instances) would be useful, but then again not good for other use cases. I think these additions would still work well within existing |
I stayed away from the custom exception and stuck with I changed the return values so they hopefully make a little more sense: e.g. implementing RFC 6902's "move" should be something like I also noticed that |
Sounds good so far. I am open to considering addition to |
} | ||
|
||
public void testAddObjectDepth2() { | ||
JsonNode n = new ObjectNode(JsonNodeFactory.instance); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion here; take JsonNodeFactory.instance, use its factory methods for creating ObjectNodes (etc) -- same for other usage too of course. Or, if tests have ObjectMapper
, use array/object node factory methods.
Conflicts: src/main/java/com/fasterxml/jackson/databind/node/ValueNode.java
Conflicts: src/main/java/com/fasterxml/jackson/databind/node/ArrayNode.java
I just saw this thread on the dev list about JSON Patch support: it got me wondering where this pull request stands? I originally introduced these changes because they make something like a JSON Patch implementation pretty easy (in fact that is what originally inspired these changes: I could probably dig that JSON Patch code back up). |
@jgustie I think I dropped the ball here. After thinking about it a bit, I think I am ok with Some remaining issues are:
Another that may or may not make sense is to try to get discussion restarted on jackson-dev list. |
You and me both, I guess I must have been pretty distracted :) I tried not to get anything specific from JSON Patch in this part of the implementation: the '-' actually comes from JSON Pointer. It's a reference to the nonexistent member after the last element in an array (the last bullet point in section 4 of RFC 6901). It doesn't make much sense when querying which would explain why it wasn't needed yet. With the error handling, I only used I'll try picking up the conversation on the dev group to see if anyone bites. |
Ah ok wrt '-'. Makes sense with that, was indeed wondering why accessor did not care about it, but makes sense. Let's go with dev group, wrt error handling. I don't have strong opinion and am interested in hearing if someone has good suggestions there. |
Ok, I create #1980 to replace |
No description provided.