当前位置:网站首页>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
边栏推荐
- C language: examples of logical operation and judgment selection structure
- Three ways for programmers to learn PHP easily and put chaos out of order
- go 函数
- 【人员密度检测】基于形态学处理和GRNN网络的人员密度检测matlab仿真
- 手撕——排序
- 【力扣刷题】15.三数之和(双指针);17.电话号码的字母组合(递归回溯)
- Pandora IOT development board learning (RT thread) - Experiment 1 LED flashing experiment (learning notes)
- 【无线图传】基于FPGA的简易无线图像传输系统verilog开发,matlab辅助验证
- Fluent icon demo
- PIP installation of third-party libraries
猜你喜欢

蓝湖的安装及使用

u本位合约爆仓清算解决方案建议
![[ibdfe] matlab simulation of frequency domain equalization based on ibdfe](/img/a1/441f400668e736b70cb36443f2267a.png)
[ibdfe] matlab simulation of frequency domain equalization based on ibdfe

First acquaintance with string+ simple usage (II)

Set vscode. When double clicking, the selected string includes the $symbol - convenient for PHP operation

Basic operations of MySQL database (based on tables)

Qt插件之Qt Designer插件实现

PR zero foundation introductory guide note 2

Microsoft Research Institute's new book "Fundamentals of data science", 479 Pages pdf

Which is better, industrial intelligent gateway or edge computing gateway? How to choose the right one?
随机推荐
潘多拉 IOT 开发板学习(RT-Thread)—— 实验1 LED 闪烁实验(学习笔记)
MySQL error: expression 1 of select list is not in group by claim and contains nonaggre
PIP installation of third-party libraries
0基础如何学习自动化测试?按照这7步一步一步来学习就成功了
The confusion I encountered when learning stm32
Feature Engineering: summary of common feature transformation methods
JVM知识点
如何解决在editor模式下 无法删除物体的问题
uni-app - 实现获取手机验证码倒计时 60 秒(手机号+验证码登录功能)
The first game of the 12th Blue Bridge Cup single chip microcomputer provincial competition
The fourth provincial competition of Bluebridge cup single chip microcomputer
近段时间天气暴热,所以采集北上广深去年天气数据,制作可视化图看下
How much is the tuition fee of SCM training class? How long is the study time?
【leetcode】74. Search 2D matrix
Suggestions on settlement solution of u standard contract position explosion
【leetcode】81. Search rotation sort array II
Pandora IOT development board learning (HAL Library) - Experiment 2 buzzer experiment (learning notes)
[JS -- map string]
Go language naming specification
Force buckle 540 A single element in an ordered array