I have a JSON object with two arrays — one keys
array and one values
array, both of the same length. Using jmespath, I want to construct a new object using the values of the keys
array as the keys and the values of the values
array as the values, like array_combine
in PHP.
For example, here's the input:
{
"keys": [
"a",
"b",
"c"
],
"values": [
1,
2,
3
]
}
And here is the output I'm expecting:
{
"a": 1,
"b": 2,
"c": 3
}
Is there any built-in function to achieve this?
Unfortunately, it looks like this is not possible yet.
Github issue: jmespath.py#152 — (located in the repo of the Python implementation)
You would need the zip
and from_items
functions, proposed (!) for the specs in this github pull request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With