Im trying to swap key to values, values to key, but could not find right solution using javascript/typescript.
course =
[
{
"name" : "John",
"course" : ["Java", "Python"]
},
{
"name" : "Michel",
"course" : ["Java", "Python", "Ruby"]
}
]
I want the result json is like below:
result = [
{
"course" : "Java",
"name" : ["John", "Michel"]
},
{
"course" : "Python",
"name" : ["John", "Michel"]
},
{
"course" : "Ruby",
"name" : ["Michel"]
}
]