当前位置:网站首页>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
边栏推荐
- Is the product of cancer prevention medical insurance safe?
- go 函数
- The 7th Blue Bridge Cup single chip microcomputer provincial competition
- The 9th Blue Bridge Cup single chip microcomputer provincial competition
- Didi open source Delta: AI developers can easily train natural language models
- The original author is out! Faker. JS has been controlled by the community..
- The 8th Blue Bridge Cup single chip microcomputer provincial competition
- Target free or target specific: a simple and effective zero sample position detection comparative learning method
- The 5th Blue Bridge Cup single chip microcomputer provincial competition
- 66.qt quick-qml自定义日历组件(支持竖屏和横屏)
猜你喜欢

Visual slam Lecture 3 -- Lie groups and Lie Algebras

Yyds dry inventory compiler and compiler tools

Spring recruitment of Internet enterprises: Kwai meituan has expanded the most, and the annual salary of technical posts is up to nearly 400000

Basic operations of MySQL database (based on tables)

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

【直播回顾】战码先锋首期8节直播完美落幕,下期敬请期待!

近段时间天气暴热,所以采集北上广深去年天气数据,制作可视化图看下

It took me only 3 months to jump out of the comfort zone and become an automated test engineer for 5 years
![[wireless image transmission] FPGA based simple wireless image transmission system Verilog development, matlab assisted verification](/img/77/4df7a1439ff1a53f94d409a19a47d6.png)
[wireless image transmission] FPGA based simple wireless image transmission system Verilog development, matlab assisted verification

The 5th Blue Bridge Cup single chip microcomputer provincial competition
随机推荐
It took me only 3 months to jump out of the comfort zone and become an automated test engineer for 5 years
潘多拉 IOT 开发板学习(HAL 库)—— 实验2 蜂鸣器实验(学习笔记)
【人员密度检测】基于形态学处理和GRNN网络的人员密度检测matlab仿真
How to model noise data? Hong Kong Baptist University's latest review paper on "label noise representation learning" comprehensively expounds the data, objective function and optimization strategy of
文档声明与字符编码
Recyclerview add header
Spring recruitment of Internet enterprises: Kwai meituan has expanded the most, and the annual salary of technical posts is up to nearly 400000
2022-07-01:某公司年会上,大家要玩一食发奖金游戏,一共有n个员工, 每个员工都有建设积分和捣乱积分, 他们需要排成一队,在队伍最前面的一定是老板,老板也有建设积分和捣乱积分, 排好队后,所有
go 包的使用
Qt插件之Qt Designer插件实现
【leetcode】74. Search 2D matrix
Force buckle 540 A single element in an ordered array
手撕——排序
C language: examples of logical operation and judgment selection structure
Go language naming specification
The 9th Blue Bridge Cup single chip microcomputer provincial competition
[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)
Welcome the winter vacation multi school league game 2 partial solution (B, C, D, F, G, H)
Object oriented thinking
一文彻底理解评分卡开发中——Y的确定(Vintage分析、滚动率分析等)