当前位置:网站首页>Introduction to JSON usage scenarios and precautions
Introduction to JSON usage scenarios and precautions
2022-07-02 04:03:00 【It mapper】
JSON The use of scenarios and precautions
JSON Of 2 A structural form
Key value pair form
{ "person": { "name": "pig", "age": "18", "sex": "man", "hometown": { "province": " Jiangxi Province ", "city": " Fuzhou City ", "county": " Chongren county " } } }
structural JSON The data rule is : A disordered “‘ name / value ’ Yes ” aggregate . An object to { Left parenthesis Start , } Right bracket end . Every “ name ” Followed by a : The colon ;“‘ name / value ’ Yes ” Used between , comma Separate
Array form
["pig", 18, "man", " Chongren County, Fuzhou City, Jiangxi Province "]
In array form JSON Data is value (value) Ordered set of . An array to [ Left bracket Start , ] Right bracket end . Use between values , comma Separate
JOSN Of 6 Type of data
- string: character string , It must be enclosed in double quotation marks
- number: The number , And JavaScript Of number Agreement , Integers ( Don't use decimal or exponential counting ) At most 15 position . The maximum number of decimal places is 17
- object:JavaScript The object form of ,{ key:value } Representation , Can be nested
- array: Array ,JavaScript Of Array Representation [ value ], Can be nested
- true/false: Boolean type ,JavaScript Of boolean type
- null: Null value ,JavaScript Of null
JSON Use scenarios
Interface returns data
JSON The most used place is Web 了 , Today's data interfaces are basically returned JSON, Specific and detailed scenes include
- Ajxa Asynchronous access to data
- RPC The remote invocation
- Separate the data returned by the back end and the front end
- to open up API, Such as Baidu 、 Some open interfaces, like Gaud
- Cooperation interface between enterprises
serialize
All variables are stored in memory when the program is running , In case of program restart or machine downtime , Then the data is lost . Some data in memory needs to be saved for the next program or other programs
Save the data in memory or in the database , Or save directly to a file , and The process of transforming data in memory into data that can be saved or transferred is called serialization
The normal serialization is to program the The object is directly converted to something that can be saved or transferred , This saves the type information of the object , and JSON Serialization does not preserve the object type
Generate Token
- Token The way to do login authentication , And then through Token selection Redis Cached user information in , After that JWT Appearance , The verification method is more simple and convenient , There is no need to pass Redis cache , It's directly based on Token Take out the saved user information , And right Token Availability check , Single sign on is easier
The configuration file
- JSON It's not the right configuration file , Because it can't write notes 、 As the readability of the configuration file is poor and so on
边栏推荐
- Monkey test
- Object oriented thinking
- 【IBDFE】基于IBDFE的频域均衡matlab仿真
- Go language introduction
- 《动手学深度学习》(二)-- 多层感知机
- Vite: configure IP access
- Learn more about materialapp and common attribute parsing in fluent
- The first game of the 12th Blue Bridge Cup single chip microcomputer provincial competition
- The difference between vectorresize and reverse.
- The second game of the 11th provincial single chip microcomputer competition of the Blue Bridge Cup
猜你喜欢
Déchirure à la main - tri
Lost a few hairs, and finally learned - graph traversal -dfs and BFS
Microsoft Research Institute's new book "Fundamentals of data science", 479 Pages pdf
手撕——排序
[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)
First acquaintance with string+ simple usage (II)
The 9th Blue Bridge Cup single chip microcomputer provincial competition
Cloud service selection of enterprises: comparative analysis of SaaS, PAAS and IAAs
The 8th Blue Bridge Cup single chip microcomputer provincial competition
Which is better, industrial intelligent gateway or edge computing gateway? How to choose the right one?
随机推荐
Nacos 配置中心整体设计原理分析(持久化,集群,信息同步)
云服务器的安全设置常识
微信小程序 - 实现获取手机验证码倒计时 60 秒(手机号+验证码登录功能)
C language: examples of logical operation and judgment selection structure
Class design basis and advanced
Blue Bridge Cup single chip microcomputer sixth temperature recorder
QT designer plug-in implementation of QT plug-in
【直播回顾】战码先锋首期8节直播完美落幕,下期敬请期待!
How about Ping An lifetime cancer insurance?
What is 5g industrial wireless gateway? What functions can 5g industrial wireless gateway achieve?
L'avènement de l'ère 5G, une brève discussion sur la vie passée et présente des communications mobiles
Vite: configure IP access
集成底座方案演示说明
Installation and use of blue lake
Is the product of cancer prevention medical insurance safe?
Demonstration description of integrated base scheme
Get started with Aurora 8b/10b IP core in one day (5) -- learn from the official routine of framing interface
跳出舒适区,5年点工转型自动化测试工程师,我只用了3个月时间
Go function
Www2022 | know your way back: self training method of graph neural network under distribution and migration