diff --git a/jmespath/functions.py b/jmespath/functions.py index 1b40fba2..5e54eb56 100644 --- a/jmespath/functions.py +++ b/jmespath/functions.py @@ -184,10 +184,6 @@ def _func_to_array(self, arg): else: return [arg] - @signature({'types': ['array']}) - def _func_to_object(self, pairs): - return dict(pairs) - @signature({'types': []}) def _func_to_string(self, arg): if isinstance(arg, STRING_TYPE): @@ -288,6 +284,10 @@ def _func_sum(self, arg): def _func_items(self, arg): return list(map(list, iteritems(arg))) + @signature({'types': ['array']}) + def _func_from_items(self, items): + return dict(items) + @signature({"types": ['object']}) def _func_keys(self, arg): # To be consistent with .values() diff --git a/tests/compliance/functions.json b/tests/compliance/functions.json index e843f58a..0de78865 100644 --- a/tests/compliance/functions.json +++ b/tests/compliance/functions.json @@ -12,7 +12,7 @@ "empty_list": [], "empty_hash": {}, "objects": {"foo": "bar", "bar": "baz"}, - "pairs": [["a", "first"], ["b", "second"], ["c", "third"]], + "items": [["a", "first"], ["b", "second"], ["c", "third"]], "null_key": null }, "cases": [ @@ -184,6 +184,10 @@ "expression": "items(numbers)", "error": "invalid-type" }, + { + "expression": "from_items(items)", + "result": {"a": "first", "b": "second", "c": "third"} + }, { "expression": "length('abc')", "result": 3 @@ -488,10 +492,6 @@ "expression": "to_array(false)", "result": [false] }, - { - "expression": "to_object(pairs)", - "result": {"a": "first", "b": "second", "c": "third"} - }, { "expression": "to_string('foo')", "result": "foo"