How to convert an object into a JSON string in JavaScript

1 Answer

0 votes
const obj = { name: "Tom", age: 56, profession: "Developer" };
const json = JSON.stringify(obj);
 
console.log(json);
 
 
 
   
/*
run:
 
{"name":"Tom","age":56,"profession":"Developer"}
 
*/

 



answered Mar 20, 2020 by avibootz

Related questions

1 answer 153 views
1 answer 149 views
1 answer 176 views
1 answer 201 views
2 answers 239 views
1 answer 158 views
1 answer 152 views
...