- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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.parse() and and explain its use in javascript?
JSON.parse()
When the data is received from web server, the data is always a string .So to change it to the object, JSON.parse() method is used.
Example
<html> <body> <script> var obj = '{"name":"Jon", "age":20, "city":"Columbia"}'; var res = JSON.parse(obj); document.write(res); console.log(res); </script> </body> </html>
output
[object object] {"name":"Jon", "age":"20", "city":"Columbia"}
Advertisements