I am currently facing a challenge in converting the following JavaScript object into valid JSON format:
[{
'"Sno"': '"1"',
'"Purchase Date Time"': '"2017-11-14 14:09:32"',
'"Txn Type"': '"COD"',
'"Order Status"': '"DELIVERED"'
},
{
'"Sno"': '"2"',
'"Purchase Date Time"': '"2017-11-14 14:09:32"',
'"Txn Type"': '"COD"',
'"Order Status"': '"DELIVERED"'
}]
Despite trying to use JSON.stringify()
, the output produced is not satisfactory:
"[{"\"Sno\"":"\"1\"","\"Purchase Date Time\"":"\"2017-11-10 14:09:32\"","\"Txn Type\"":"\"COD\"","\"Order Status\"":"\"DELIVERED\"",}]"
This current representation hinders my ability to access individual elements effectively. What I really need is the ability to retrieve values like objectName[i].Sno
.
What steps can I take to achieve this desired outcome?