jmespath.site icon indicating copy to clipboard operation
jmespath.site copied to clipboard

added items, to_object and zip functions to specification

Open jstewmon opened this issue 9 years ago • 3 comments
trafficstars

fixes jmespath/jmespath.jep#20

jstewmon avatar Mar 21 '16 14:03 jstewmon

:+1: yesss!

bosr avatar Apr 02 '16 06:04 bosr

Given [["one", 1], ["two", 2], ["one", 3]] what should be the output of from_items(@)? Possible candidates could be: {"one": 1, "two": 2} or {"one": 3, "two": 2} or {"one": [1,3], "two": 2}

shashankmehra avatar May 15 '17 20:05 shashankmehra

@shashankmehra the last pair for any key will win, so in your example, the result will be: {"one": 3, "two": 2}.

This is consistent with _.fromPairs in JavaScript:

> _.fromPairs([["one", 1], ["two", 2], ["one", 3]])
{ one: 3, two: 2 }

And dict construction in python:

>>> dict([["one", 1], ["two", 2], ["one", 3]])
{'two': 2, 'one': 3}

jstewmon avatar May 15 '17 20:05 jstewmon