jmespath / jmespath.py

JMESPath is a query language for JSON.
http://jmespath.org
MIT License
2.19k stars 181 forks source link

Struggling with usage of Merge function #312

Open ChaitanyaKandala opened 1 year ago

ChaitanyaKandala commented 1 year ago

Hi, I am trying to pass 2 dicts/arrays to the merge but I am not able to figure out how to do that. Can I get some help here please? I tried various things but I can only get this to work. print(jmespath.search('merge({"a":"b"},{"a":"c", "b":"z"})', {}))

What do I do if I need to pass arguments? Like I have these 2 dictionaries. one = {"a":"b"} two = {"a":"c", "b":"z"} What am I missing?

springcomp commented 1 year ago

You cannot pass arguments to JMESPath currently, however, you could supply a single input JSON like so: Given:

{
  "one": {"a": "b"},
  "two": {"a": "c", "b": "z"}
}

The following expression will do the merge for you:

Please, head over to the discussion ### chat for more reactive help.