convert object to json javascript

JavaScript
var person={"first_name":"Tony","last_name":"Hawk","age":31};
var personJSONString=JSON.stringify(person); var obj = {name: "Martin", age: 30, country: "United States"};
 
// Converting JS object to JSON string
var json = JSON.stringify(obj);
 
console.log(json);
// Prints: {"name":"Martin","age":30,"country":"United States"} 
"https://www.tutorialrepublic.com/faq/how-to-convert-js-object-to-json-string.php"var jsonArray = JSON.parse(JSON.stringify(pluginArrayArg))// Imagine we received this text from a web server:
'{ "name":"John", "age":30, "city":"New York"}'

// To convert text into a JavaScript object, use the JavaScript function JSON.parse():
var obj = JSON.parse('{ "name":"John", "age":30, "city":"New York"}');

// OR
var string = '{ "name":"John", "age":30, "city":"New York"}';
var obj = JSON.parse(string);
Source

Also in JavaScript: