- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is JSON.stringify() and explain its use in javascript?
JSON.stringify()
If we need to send data to a web server the data should be a string.To change the object literal to string JSON.stringify() method should be used.For instance
Example-1
<html> <body> <p id="demo"></p> <script> var obj = {name:"rekha", age:40, city:"newyork"}; var myJSON = JSON.stringify(obj); document.getElementById("demo").innerHTML = myJSON; </script> </body> </html>
Output
{"name":"rekha","age":40,"city":"newyork"}
Example-2
<html> <body> <p id="demo"></p> <script> var obj = {"name":"ramesh","age":30,"family": [{"mother":"geetha","father":"rao"}],"city":"berlin"}; var myJSON = JSON.stringify(obj); document.getElementById("demo").innerHTML = myJSON; </script> </body> </html>
Output
{"name":"ramesh","age":30,"family":[{"mother":"geetha","father":"rao"}],"city":"berlin"}
- Related Articles
- What is JSON.parse() and and explain its use in javascript?
- JavaScript JSON.stringify() with Example
- What is the fetchone() method? Explain its use in MySQL Python?
- Why do we use JSON.stringify() method in jQuery?
- What is Java API and what is its use?
- What is a Periscope and what is its ;use?
- What is OLAP? Explain its advantages and disadvantages
- What is bootstrap and what is its use as a framework?
- What is an acquisition strategy and explain its types and elements?
- What is definition of business finance and explain its types?
- What is query optimization and explain its two forms(DBMS)?
- What is the hedge ratio? Explain its advantages and disadvantages.
- What is RDBMS? Explain its major functions
- What is a triangle? Explain its properties.
- What is translational motion? Explain its types.

Advertisements