Hi there! I am receiving an array of nested JSON elements and I would like to build a logic capable of transforming the following input
{
"devices": [
{
"device": {
"device_name": "printer_1",
"other_field1": "abc",
"other_field2": "def"
},
"category": {
"category_name": "printers",
"other_field3": "ghi",
"other_field4": "jkl"
},
"device_id": "1234567890"
},
{
"device": {
"device_name": "printer_2",
"other_field1": "abc",
"other_field2": "def"
},
"category": {
"category_name": "printers",
"other_field3": "ghi",
"other_field4": "jkl"
},
"device_id": "0987654321"
},
{
"device": {
"device_name": "laptop_1",
"other_field1": "abc",
"other_field2": "def"
},
"category": {
"category_name": "laptops",
"other_field3": "ghi",
"other_field4": "jkl"
},
"device_id": "2468013579"
}
]
}
in this output:
{
"printers": ["printer_1", "printer_2"],
"laptops": ["laptop_1"]
}
Thanks!