I have encountered a challenge with transforming an array. The original array looks like this:
array = [
{
"name": "name",
"value": "Olá"
},
{
"name": "age",
"value": "23"
},
{
"name": "isVisible",
"value": "1"
}
]
The goal is to convert it into the following string format:
"{\"name\":\"Olá\",\"age\":123,\"isVisible\":true}"
Despite attempting various methods, I have not been successful in achieving this. My most recent attempt was as follows:
array = array.map((p) => {
return Object.values(p).join(':').replace(/\[/g, '{').replace(/]/g, '}').toString();
}),
Any suggestions or solutions would be greatly appreciated.