Skip to content

Commit bc92aae

Browse files
author
Jonathan Stewmon
committed
rename to_object to from_items
1 parent b1709c3 commit bc92aae

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

jmespath/functions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,6 @@ def _func_to_array(self, arg):
187187
else:
188188
return [arg]
189189

190-
@signature({'types': ['array']})
191-
def _func_to_object(self, pairs):
192-
return dict(pairs)
193-
194190
@signature({'types': []})
195191
def _func_to_string(self, arg):
196192
if isinstance(arg, STRING_TYPE):
@@ -291,6 +287,10 @@ def _func_sum(self, arg):
291287
def _func_items(self, arg):
292288
return list(map(list, iteritems(arg)))
293289

290+
@signature({'types': ['array']})
291+
def _func_from_items(self, items):
292+
return dict(items)
293+
294294
@signature({"types": ['object']})
295295
def _func_keys(self, arg):
296296
# To be consistent with .values()

tests/compliance/functions.json

Lines changed: 5 additions & 5 deletions
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": [
@@ -188,6 +188,10 @@
188188
"expression": "items(numbers)",
189189
"error": "invalid-type"
190190
},
191+
{
192+
"expression": "from_items(items)",
193+
"result": {"a": "first", "b": "second", "c": "third"}
194+
},
191195
{
192196
"expression": "length('abc')",
193197
"result": 3
@@ -492,10 +496,6 @@
492496
"expression": "to_array(false)",
493497
"result": [false]
494498
},
495-
{
496-
"expression": "to_object(pairs)",
497-
"result": {"a": "first", "b": "second", "c": "third"}
498-
},
499499
{
500500
"expression": "to_string('foo')",
501501
"result": "foo"

0 commit comments

Comments
 (0)