Skip to content

Commit 3016b06

Browse files
author
Jonathan Stewmon
committed
rename to_object to from_items
1 parent e34147c commit 3016b06

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

jmespath/functions.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,6 @@ def _func_to_array(self, arg):
184184
else:
185185
return [arg]
186186

187-
@signature({'types': ['array']})
188-
def _func_to_object(self, pairs):
189-
return dict(pairs)
190-
191187
@signature({'types': []})
192188
def _func_to_string(self, arg):
193189
if isinstance(arg, STRING_TYPE):
@@ -288,6 +284,10 @@ def _func_sum(self, arg):
288284
def _func_items(self, arg):
289285
return list(map(list, iteritems(arg)))
290286

287+
@signature({'types': ['array']})
288+
def _func_from_items(self, items):
289+
return dict(items)
290+
291291
@signature({"types": ['object']})
292292
def _func_keys(self, arg):
293293
# To be consistent with .values()

tests/compliance/functions.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"empty_list": [],
1313
"empty_hash": {},
1414
"objects": {"foo": "bar", "bar": "baz"},
15-
"pairs": [["a", "first"], ["b", "second"], ["c", "third"]],
15+
"items": [["a", "first"], ["b", "second"], ["c", "third"]],
1616
"null_key": null
1717
},
1818
"cases": [
@@ -184,6 +184,10 @@
184184
"expression": "items(numbers)",
185185
"error": "invalid-type"
186186
},
187+
{
188+
"expression": "from_items(items)",
189+
"result": {"a": "first", "b": "second", "c": "third"}
190+
},
187191
{
188192
"expression": "length('abc')",
189193
"result": 3
@@ -488,10 +492,6 @@
488492
"expression": "to_array(false)",
489493
"result": [false]
490494
},
491-
{
492-
"expression": "to_object(pairs)",
493-
"result": {"a": "first", "b": "second", "c": "third"}
494-
},
495495
{
496496
"expression": "to_string('foo')",
497497
"result": "foo"

0 commit comments

Comments
 (0)