I have a JSON object array where I need to rename the keys based on values in the first object. Trying to do this in NodeJS but not having any luck.
I could probably brute force it with a couple of loops but was hoping for a more scalable solution since the number of "columns" change from time to time.
Here is an example
[{"A" : "Key1", "B" : "Key2", "C" : "Key3"},
{"A" : "Data1", "B" : "Data2", "C" : "Data3"},
{"A" : "Data5", "B" : "Data5", "C" : "Data7"}]
I would like the result to be like
[{"Key1" : "Key1", "Key1" : "Key2", "Key1" : "Key3"},
{"Key1" : "Data1", "Key2" : "Data2", "Key3" : "Data3"},
{"Key1" : "Data5", "Key2" : "Data5", "Key3" : "Data7"}]