I have been attempting to switch keys with values and vice versa, but I haven't been able to find the correct solution using JavaScript/TypeScript.
course =
[
{
"name" : "John",
"course" : ["Java", "Python"]
},
{
"name" : "Michel",
"course" : ["Java", "Python", "Ruby"]
}
]
The desired JSON output should be:
result = [
{
"course" : "Java",
"name" : ["John", "Michel"]
},
{
"course" : "Python",
"name" : ["John", "Michel"]
},
{
"course" : "Ruby",
"name" : ["Michel"]
}
]