If I have an array in the following format:
[0]:
["id_1"]:
prop1: "abc"
prop2: "def"
["id_2"]:
prop1: "ghi"
prop2: "jkl"
[1]:
["id_3"]:
prop1: "mno"
prop2: "pqr"
["id_4"]:
prop1: "stu"
prop2: "vwx"
How could I map that into an array using the following format:
[0]:
key: "id_1"
prop1: "abc"
prop2: "def"
[1]:
key: "id_2"
prop1: "ghi"
prop2: "jkl"
[2]:
key: "id_3"
prop1: "mno"
prop2: "pqr"
[4]:
key: "id_4"
prop1: "stu"
prop2: "vwx"
I've tried using flatten functions as described here: Merge/flatten an array of arrays in JavaScript? but i'm not sure how i'd set the key for each flattened child element.