I am currently working with a JSON object that has the following structure:
{"Firstname":"john","Lastname":"doe"}
My goal is to transform it into an array with a specific name 'abc':
users: [{"Firstname":"john","Lastname":"doe"}]
This is how I am constructing my object using input values:
var obj = {};
obj.Firstname = document.getElementById("firstName").value;
obj.Lastname = document.getElementById("surname").value;
console.log(obj);
var jsonStringObj = JSON.stringify(obj);
console.log(jsonStringObj );
and when I run this code, it outputs:
{"Firstname":"john","Lastname":"doe"}
Thank you for your help!