I'm trying to transform my object person
to a JSON.
const person = new Object();
person.firstName = 'testFirstName';
person.lastName = 'testLastName';
var myJson = JSON.stringify(person);
console.log(myJson);
console.log(typeof myJson); // This returns me a string, not a JSON.
But when I try to print my supposed JSON and print the type of my element (myJson
) I get is an string
.
Someone can help me to understand this and can tell me how I could do this?