My current task involves using Papaparse to convert a csv file into a json object.
The API requires the data to be structured like this:
"data": [
{
"id": 1,
"nombre": "AGUASBLANCAS-AGB",
"descripcion": "-",
"it_unidad_generadora": 0
},
{
"id": 425,
"nombre": "AGUASBLANCAS-AGBQ",
"descripcion": "-",
"it_unidad_generadora": 403
}
]
However, after using Papaparse, the csv gets converted into an array of arrays representing each row like this:
"data": [
0: ["ID", "NOMBRE", "DESCRIPCIÓN", "IT UNIDAD GENERADORA"]
1: ["1", "AGUASBLANCAS-AGB", "-", "0"]
2: ["425", "AGUASBLANCAS-AGBQ", "-", "403"]
]
I am looking for a way to transform this into a JSON array of objects using Papaparse, rather than an array of arrays representing each row. Can anyone provide guidance on achieving this?