jmespath / jmespath/jmespath.jep
Function proposal - entries()
- Dominant language
- Python
- Stars
- 10
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
Given a `array` or `object` output an array with values indexed on keys:
For example in Javascript one might implement it as follows:
```javascript
registerFunction(
'entries',
([resolvedArgs]) => {
return Object.entries(resolvedArgs);
},
[{ types: [TYPE_OBJECT, TYPE_ARRAY] }],
);
```
Examples:
```javascript
// With ARRAY input:
jmespath.search([1,"2", null, ["a", 2, "foo"], {b: "z"}, true, false], "entries(@)")
// OUTPUTS: [
// [ '0', 1 ],
// [ '1', '2' ],
// [ '2', null ],
// [ '3', [ 'a', 2, 'foo' ] ],
// [ '4', { b: 'z' } ],
// [ '5', true ],
// [ '6', false ]
// ]
```
```javascript
// With **OBJECT** input:
jmespath.search({a: 1, b: [2, 3], c: null, 4: {x: 0}}, 'entries(@)')
// OUTPUTS: [
// [ '4', { x: 0 } ],
// [ 'a', 1 ],
// [ 'b', [ 2, 3 ] ],
// [ 'c', null ]
// ]
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.