当前位置:网站首页>JSON. Stringify() and JSON parse()
JSON. Stringify() and JSON parse()
2022-04-21 17:55:00 【Elephants and ants】
First understand JSON and JS Relationship of objects
JSON:let str = ‘{“a”:“test”,“b”:123}’ // This is a JSON character string , The essence is a string
JS object :let str = { a: ‘test’, b: 123 } // This is an object , Note that key names can also be enclosed in quotation marks
JSON yes JS String representation of object , It uses text to represent a JS Object information , The essence is a string .
- JSON.stringify() : take JS Object to JSON Format
` // The test case 1:
let str = {
a: 'test', b: 123};
console.log('-----------str:', JSON.stringify(str));
-----------str: {
"a":"test","b":123}
- JSON.parse() : take JSON Converts a string to an object
// The test case 1:
let str = '{"a":"test","b":123}';
console.log('----------str :', JSON.parse(str ));
----------str : {
a: 'test', b: 123 }
let str2 = [1, 2, 3];
let str3 = JSON.stringify(str2); // '[1,2,3]'
let str4 = JSON.parse(str3); // [1,2,3]
console.log('-----------str3:', str3, typeof str3);
console.log('-----------str4:', str4, typeof str4);
-----------str3: [1,2,3] string
-----------str4: [ 1, 2, 3 ] object
版权声明
本文为[Elephants and ants]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211748085801.html
边栏推荐
- MySQL进阶之表的增删改查
- 吃了这个开源小玩意让单片机开发和Arduino一样高效
- SQL command delete (I)
- The difference between MSIL static class and non static class in IL definition
- Is qiniu financial management useful? Is it safe?
- What happens when the user sends a request to execute the controller method
- SQL命令 DELETE(一)
- 使用K3S创建本地开发集群
- Logstash ~ configuration file of logstash
- Deep cultivation of the industry for decades, interpretation from multiple perspectives! Digital IT operation from the perspective of thinking transformation
猜你喜欢

【acwing】166. 数独****(DFS)

Fonctions communes pour MySQL Advanced

MySQL進階之常用函數

动态规划:硬币题目总结

VS2019 visual studio 终端调试乱码问题

MySQL进阶之常用函数

Vulnerability detection and defense: redis unauthorized access vulnerability recurrence

科技云报道:DPU市场火热,未来会任由几家大厂吃独食吗?

Deep cultivation of the industry for decades, interpretation from multiple perspectives! Digital IT operation from the perspective of thinking transformation

洞见科技首批通过央行国家金融科技测评中心「联邦学习」产品评测,实现「MPC+FL」金融应用双认证
随机推荐
Detailed explanation of spark SQL underlying execution process
【Redis】 使用Redis优化省份展示数据不显示
看看项目经理是如何把一个项目带崩的
Logstash ~ configuration file of logstash
Logstash ~ how logstash works
Fonctions communes pour MySQL Advanced
"Industrial Internet plus safety production" to enhance the safety level of industrial enterprises
numpy.ndarray不支持逻辑运算
Logstash ~ logstash command line optional parameters
Addition, deletion, modification and query of MySQL advanced table
ASE35P03-ASEMI场效应管35P03
Shell programming learning (III) condition judgment and process control
LogStash~LogStash的执行模型
MySQL localization workbench localization XML file
LAXCUS分布式操作冗余容错之节点篇
使用K3S创建本地开发集群
漏洞检测与防御:Redis未授权访问漏洞复现
torch.max()的用法
终于有人讲明白了!原来这才是全球低时延一张网技术
Thesis | attention based bidirectional long short term memory networks for relation classification