Skip to content

Set multiple values  #153

Open
Open
@arielrimon

Description

@arielrimon

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"}]}

Activity

moomoohk

moomoohk commented on Sep 6, 2021

@moomoohk
Collaborator

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @moomoohk@arielrimon

        Issue actions

          Set multiple values · Issue #153 · dpath-maintainers/dpath-python