google / google/jsonnet

iterating through objects as key value pairs (cf. pythons .items())

Open
#543 8 comments 6 reactions 0 assignees View on GitHub
enhancement stdlib
Dominant language
Jsonnet
Stars
7.6k
Forks
475
PR merge metrics
No merged PRs in 30d

Description

sometimes it's useful to process objects by iterating through the key value pairs

python has

```
obj = {"a": 1, "b": 2}
{k:v*2 for k,v in obj.items()}
```

jq has

```
echo '{"a": 1, "b": 2}'|jq '[to_entries[]|{key: .key, value: (.value * 2)}]|from_entries'
```

is there something similar in jsonnet? it seems like the list and object comprehensions could return (k,v) tuples if the right hand side is an object

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.