Skip to content

Set multiple values  #153

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

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

      Issue actions