Back
If I have an object like this:
var j={"name":"Virat"};
How can I convert the object to JSON? The output string should be:
'{"name":"Virat"}'
You can convert a js object JSON string by using JSON.stringify() function. For example:
Var obj={‘name’:"Virat"};console.log(JSON.stringify(obj));
Var obj={‘name’:"Virat"};
console.log(JSON.stringify(obj));
Interested in Web Development? Check out this web developer certification by Intellipaat.
31k questions
32.8k answers
501 comments
693 users