I have a parent object containing the following data
[
{
"BEGIN_TIME": "24 Feb 2023 13:36",
"END_TIME": "24 Feb 2023 13:37",
...
},
{
"BEGIN_TIME": "24 Feb 2023 13:37",
"END_TIME": "24 Feb 2023 13:38",
...
},
{
"BEGIN_TIME": "24 Feb 2023 13:38",
"END_TIME": "24 Feb 2023 13:39",
...
}
]
I want to create an array containing specific property of a parent object.
For instance, I need all values of END_TIME property. Something like following
child_array=parent_json.Get(END_TIME);
Expected result
["24 Feb 2023 13:37","24 Feb 2023 13:38","24 Feb 2023 13:39"]
>Solution :
You can use map function
const child_array = parent_json.map(obj => obj.END_TIME);
console.log(child_array);
// Output: ["24 Feb 2023 13:37", "24 Feb 2023 13:38", "24 Feb 2023 13:39"]
Enjoy with this