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

Set multiple values #153

Open
arielrimon opened this issue Sep 3, 2021 · 1 comment
Open

Set multiple values #153

arielrimon opened this issue Sep 3, 2021 · 1 comment

Comments

@arielrimon
Copy link

arielrimon commented Sep 3, 2021

Hi,
I would like to know if there is an option to set multiple values, like I can get multiple values.
For example:

import dpath.util

simple_json = {"a": [{"1": "b"}, {"1": "c"}]}
extracted_list = dpath.util.values(simple_json,"a/*/1")
print(extracted_list)
# ['b', 'c']
new_list = ["d","e"]
extracted_list = dpath.util.set(simple_json,"a/*/1",new_list)
print(simple_json)
# {"a": [{"1": "d"}, {"1": "e"}]}
@moomoohk
Copy link
Collaborator

moomoohk commented Sep 6, 2021

Hey Ariel,
There doesn't appear to be a built in way to do this at the moment.
I'm still getting familiar with the code, once I'm done I'll consider adding this feature.
A pull request will also be more than welcome :)

שנה טובה!

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

No branches or pull requests

2 participants