Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the use of JSON.parse function and JSON.stringify function in JavaScript

Shulou Source: shulou.com Published: 2022-06-03 20:07:18 11月12日 Update

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!

Tags: Functions content articles characters strings objects results can be learn help run easy to understand more organization knowledge editing industry information information channels channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Xiaomi OPPO Reno MariaDB NVidia