Skip to content
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

Add ArrayNode#set(int index, primitive_type value) #3154

Closed
TarekkMA opened this issue May 15, 2021 · 4 comments · Fixed by #3156
Closed

Add ArrayNode#set(int index, primitive_type value) #3154

TarekkMA opened this issue May 15, 2021 · 4 comments · Fixed by #3156

Comments

@TarekkMA
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Currently, we could add/insert values to ArrayNode instance. but the set method only accepts JsonNode instance.

Describe the solution you'd like
It would be nice if we have set methods like add/insert

Usage example

ArrayNode arr = getNewArrayNode();
arr.add("a");
arr.insert(0, "b");
arr.set(0, "c");        // <------- Missing

Additional context
N/A

@TarekkMA TarekkMA added the to-evaluate Issue that has been received but not yet evaluated label May 15, 2021
@TarekkMA
Copy link
Contributor Author

If this is accepted, I will be happy to make a PR for it.

@cowtowncoder
Copy link
Member

cowtowncoder commented May 15, 2021

Sounds reasonable. I think it should probably follow example of ObjectNode.put() so that:

  1. A wide variety of types are supported (and esp. important is primitive-and-wrapper variants)
  2. Returns ObjectNode (this) to allow call chaining.
  3. On (1), no need to add setObject(), I think (since there is already set(index, JsonNode)) -- but need to add setPOJO(index, pojo) -- this since there is bit of confusion otherwise on what "Object" means; here it MUST mean ObjectNode, and not general Java Object (hence "POJO").

It might also make sense to post on jackson-dev google group to ask for input: this makes sense to me but others might be able to offer comments.

Also: needs to go in 2.13 branch, being feature add.

@cowtowncoder cowtowncoder added 2.13 and removed to-evaluate Issue that has been received but not yet evaluated labels May 15, 2021
@TarekkMA
Copy link
Contributor Author

Thank you for the feedback I will post this issue on the google group for more comments about it.

@cowtowncoder
Copy link
Member

Thank you again @TarekkMA for contributing this! It will be included in 2.13.0 once that is ready (hoping to get release candidate out during June 2021).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants