What is the use of JSON.parse function and JSON.stringify function in JavaScript
This article mainly shows you "what is the use of JSON.parse function and JSON.stringify function in JavaScript", the content is simple and easy to understand, and the organization is clear. I hope it can help you solve your doubts. Let Xiaobian lead you to study and learn "what is the use of JSON.parse function and JSON.stringify function in JavaScript" in this article.
1. JSON.parse function: Use JSON.parse to convert a JSON string to an object.
Document var jsontext = '{"Name":"xiaohuzi","Age":"26","Email":"xiaohuzi@test.com","Phone":"123456789"}'; var p = JSON.parse(jsontext); alert(p.Name + ", " + p.Age+", "+p.Email+", "+p.Phone);
Run Results:
2. JSON.stringify function: converts JavaScript objects into Json representation strings.
Document var Person = new Object(); Person.Name = "XiaoHuzi"; Person.Age = 26; Person.Email="XiaoHuzi@test.com"; var jsonText = JSON.stringify(Person); alert(jsonText);
operation results
The above is "What is the use of JSON.parse function and JSON.stringify function in JavaScript" All the contents of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!