I need to convert all values in a JSON object into strings. These values could be numbers, booleans, undefined, or null.
{
"obj1": [{
"n1": "n",
"n2": 1,
"n3": true
},
{
"n1": "n",
"n2": 1,
"n3": null
}]
}
The desired outcome is for all values to be converted to string
.
Example:
{
"obj1": [{
"n1": "n",
"n2": "1",
"n3": "true"
},
{
"n1": "n",
"n2": "1",
"n3": "null"
}]
}
We can achieve this by iterating through the JSON object, but I am wondering if there is a simpler method to accomplish this task.