0

<!DOCTYPE html>
<html>
<body>

<h2>Create a JSON string from a JavaScript object.</h2>
<p id="demo"></p>

<script>
const getObj = {name: "James", country: "USA", city: "Portland"};
const getJSON = JSON.stringify(getObj);
document.getElementById("demo").innerHTML = getJSON;
</script>

</body>
</html>

Output:

How to Create a JSON string from a JavaScript object
Working Code Asked question July 6, 2023