Tools, FAQ, Tutorials:
JSON-stringify.html - JSON.stringify() Example Code
Where to get a JSON.stringify() Example Code in JavaScript?
✍: FYIcenter.com
Here is a good JSON.stringify() example code in JavaScript.
<!-- JSON-stringify.html
Copyright (c) FYIcenter.com
-->
<html>
<body>
<script type="text/javascript">
var str1 = JSON.stringify(2020); // A number value
var str2 = JSON.stringify("foo"); // A string value
var str3 = JSON.stringify(true); // A Boolean value
var str4 = JSON.stringify(null); // A null
var str5 = JSON.stringify([1, 5, "false"]); // An array
var str6 = JSON.stringify({}); // An empty Object
var str7 = JSON.stringify({"msg": "Hi!"}); // An Object
document.write("<p>String from JSON.stringify():</p>");
document.write("<pre>");
document.write(" str1 = "+str1+"\n");
document.write(" str2 = "+str2+"\n");
document.write(" str3 = "+str3+"\n");
document.write(" str4 = "+str4+"\n");
document.write(" str5 = "+str5+"\n");
document.write(" str6 = "+str6+"\n");
document.write(" str7 = "+str7+"\n");
document.write("</pre>");
</script>
</body>
</html>
Save the above code in a file, JSON-stringify.html, and open it in a Web browser. You see the following output:
String from JSON.stringify():
str1 = 2020
str2 = "foo"
str3 = true
str4 = null
str5 = [1,5,"false"]
str6 = {}
str7 = {"msg":"Hi!"}
⇒ JSON-stringify-Object.html - JSON.stringify() on Objects
2021-08-04, ∼4393🔥, 1💬
Popular Posts:
How to access URL template parameters from "context.Request.Matched Parameters"object in Azure API P...
How to use the RSS Online Validator at w3.org? You can follow this tutorial to learn how to use the ...
How to install "C++/CLI Support" component in Visual Studio? I need to build my Visual Studio C++/CL...
How to use the JSON to XML Conversion Tool at utilities-online.info? If you want to try the JSON to ...
How To Read a File in Binary Mode in PHP? If you have a file that stores binary data, like an execut...