I have the following JavaScript object which prints the following JSON using
var str = JSON.stringify(finalNodesData, null, 2);
console.log(str);
Printed JSON
[
{
"jobDate": "2023-01-03 13:48:29.402",
"id": "b186c313-a2f3-44a8-9803-066c6d52e8a0"
},
{
"jobDate": "2023-01-03 13:57:19.988",
"id": "db182f5e-9622-42e9-bbe8-19bee4d878d4"
}
]
How can I add two new elements "submitedBy" and "submitReason" to the JSON? I want my JSON to look like
{
"submitedBy": "Bob Smith",
"submitReason": "Because of an error",
"nodeData": [
{
"jobDate": "2023-01-03 13:48:29.402",
"id": "b186c313-a2f3-44a8-9803-066c6d52e8a0"
},
{
"jobDate": "2023-01-03 13:57:19.988",
"id": "db182f5e-9622-42e9-bbe8-19bee4d878d4"
}
]
}
I want to use JavaScript variables to generate the JSON, and not concatenate strings.