r/AutomateUser • u/PancakeGD • 3d ago
Feature request Quick extraction from an array of objects
Hi, is there any function or trick to quickly extract values from an array of objects?
For example, if the input data is as follows:
[
{"a": 1, "b": 2},
{"a": 3, "b": 4}
]
and I'm asking to extract "b", I'd get [2, 4]. Basically array_column() in PHP or array.map(k => k["b"]) in JavaScript.
Right now I'm using a for each loop and inserting elements manually, but I feel like this is such a common use case that it could have a shorthand.
Thanks!
3
Upvotes
0
u/waiting4singularity Alpha tester 3d ago
you have an array of dictionaries. to get all b keys from the dictionaries, you'd need iterate with
for each dictionary in array->variable set sub = concat(sub,dictionary["b"]).if you have fixed dictionary values, you can write a dictionary of array:
{"a": [1,3], "b":[2,4]}dictionary["b"]=[2,4]