After using Papa Parse to generate a JSON from a CSV file, the structure of the JSON appears as follows:
{ object, object, object, .... , object }
Now, I have a requirement to transform this JSON into the following format:
{ "publication" :
{
"id" : 1,
"name" : "name1"
},
"publication" :
{
"id" : 2,
"name" : "name2"
},
"publication" :
{
"id" : 3,
"name" : "name3"
}
}
Each occurrence of "publication" should have properties like "id" and "name" nested within it.
To make this transformation using JavaScript, we can loop through each object in the original JSON and create a new JSON that conforms to the desired structure.
Thank you.