Skip to content

Commit 82df48e

Browse files
Jonathan StewmonMaxime LABELLE
authored andcommitted
rename to_object to from_items
1 parent 6a849f5 commit 82df48e

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
@@ -188,10 +188,6 @@ def _func_to_array(self, arg):
188188
else:
189189
return [arg]
190190

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

291+
@signature({'types': ['array']})
292+
def _func_from_items(self, items):
293+
return dict(items)
294+
295295
@signature({"types": ['object']})
296296
def _func_keys(self, arg):
297297
# 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)