Chapter 21 深入理解JSON

news2024/11/26 18:22:05

欢迎大家订阅【Python从入门到精通】专栏,一起探索Python的无限可能!

文章目录

  • 前言
  • 一、JSON数据格式
    • 1. 什么是JSON?
    • 2. JSON数据的格式
  • 二、JSON格式数据转化
  • 三、格式化JSON数据的在线工具


前言

在当今数据驱动的世界中,JSON(JavaScript Object Notation)作为一种轻量级的数据交换格式,得到了广泛的应用。本章详细讲解了JSON数据格式的基本概念、JSON格式的数据转化以及推荐一些实用的在线工具来帮助用户格式化JSON数据。


本篇文章参考:黑马程序员

一、JSON数据格式

1. 什么是JSON?

JSON是一种轻量级的数据交互格式,采用完全独立于编程语言的文本格式来存储和表示数据,本质上是一个带有特定格式的字符串。JSON负责不同编程语言中的数据传递和交互,类似国际通用语言中的英语。
各种编程语言存储数据的容器不尽相同,在Python中有字典dict这样的数据类型,而其它语言可能没有对应的字典。为了让不同的语言都能够相互通用的互相传递数据,JSON就是一种非常良好的中转数据格式。如下图,以Python和C语言互传数据为例:
在这里插入图片描述

2. JSON数据的格式

①基本结构
JSON是一个键值对(key/value)的集合。

  • 键:必须是字符串类型
  • 值:可以是字符串、数字、布尔值、数组、对象(即嵌套的键值对集合)以及null

②格式规范

  • 必须以开头的{[开始,并以对应的 }] 结尾
  • 所有的键名必须是双引号括起来的字符串
  • 数组和对象中的元素或成员之间用逗号 , 分隔,最后一个元素或成员后面可以有或没有逗号,但建议不加,以保持一致性。
# 写法一:
[{"name":"小明","age":11},{"name":"小红","age":15},{"name":"小玉","age":17}]
# 写法二:
{"name":"小菲","address":"北京"}

二、JSON格式数据转化

①序列化
使用json.dumps()函数可以将Python对象序列化为JSON格式的字符串。

# 导入JSON模块
import json

# 准备符合json格式要求的python数据
data=[{"name":"小明","age":11},{"name":"小红","age":15},{"name":"小玉","age":17}]
# 通过 json.dumps(data) 方法把python数据转化为了json数据
json_str=json.dumps(data)
print(type(json_str))
print(json_str)

输出结果:
<class ‘str’>
[{“name”: “\u5c0f\u660e”, “age”: 11}, {“name”: “\u5c0f\u7ea2”, “age”: 15}, {“name”: “\u5c0f\u7389”, “age”: 17}]

如果有中文可以带上ensure_ascii=False参数来确保中文的正常转换。

# 导入JSON模块
import json

# 准备符合json格式要求的python数据
data=[{"name":"小明","age":11},{"name":"小红","age":15},{"name":"小玉","age":17}]
# 通过 json.dumps(data) 方法把python数据转化为了json数据
json_str=json.dumps(data,ensure_ascii=False)
print(type(json_str))
print(json_str)

# 准备符合json格式要求的python数据
data2={"name":"小菲","address":"北京"}
json_str2=json.dumps(data2,ensure_ascii=False)
print(type(json_str2))
print(json_str2)

输出结果:
<class ‘str’>
[{“name”: “小明”, “age”: 11}, {“name”: “小红”, “age”: 15}, {“name”: “小玉”, “age”: 17}]
<class ‘str’>
{“name”: “小菲”, “address”: “北京”}

②反序列化
使用json.loads()函数可以将JSON格式的字符串反序列化为Python对象。

# 导入JSON模块
import json
# 通过 json.loads(data)方法把json数据转化为了 python数据
s1='[{"name":"小明","age":11},{"name":"小红","age":15},{"name":"小玉","age":17}]'
l1=json.loads(s1)
print(type(l1))
print(l1)

s2='{"name":"小菲","address":"北京"}'
l2=json.loads(s2)
print(type(l2))
print(l2)

输出结果:
[{‘name’: ‘小明’, ‘age’: 11}, {‘name’: ‘小红’, ‘age’: 15}, {‘name’: ‘小玉’, ‘age’: 17}]
<class ‘dict’>
{‘name’: ‘小菲’, ‘address’: ‘北京’}

问题:在编写代码的过程中我们会发现如下图那样编写会报错。
在这里插入图片描述
出现错误的原因是双重引号的使用问题。在Python中使用双引号"来定义字符串时,如果字符串中又包含了双引号",则会导致Python解析字符串时出现混淆,无法正确解析字符串的边界和内容,从而引发语法错误。

解决方案:

  • 转义内部双引号:
    在字符串中的双引号"前面加上反斜杠\进行转义
s1 = "[{\"name\":\"小明\",\"age\":11},{\"name\":\"小红\",\"age\":15},{\"name\":\"小玉\",\"age\":17}]"
  • 使用单引号包裹外部字符串:
s1 = '[{"name":"小明","age":11},{"name":"小红","age":15},{"name":"小玉","age":17}]'

【例题】
以下为一个不符合规范的JSON文件,请通过代码取出其日期数据。
在这里插入图片描述

# 导包
import json

# 处理数据
f_us=open("D:/美国.txt","r",encoding="UTF-8")
# 读取美国的全部内容
us_data=f_us.read()
# 去掉不合JSON规范的开头
us_data=us_data.replace("jsonp_1629344292311_69436(","")
# 去掉不合JSON规范的结尾
us_data=us_data[:-2]
# JSON转python字典
us_dict=json.loads(us_data)
# 获取trend key
trend_data=us_dict["data"][0]["trend"]
# 获取日期数据
date=trend_data["updateDate"]
print(date)

输出结果:
[‘2.22’, ‘2.23’, ‘2.24’, ‘2.25’, ‘2.26’]

三、格式化JSON数据的在线工具

虽然JSON格式清晰易懂,但当数据量大或嵌套层次深时,手动阅读和编辑JSON数据可能会变得非常困难。在这种情况下,格式化工具显得尤为重要。
JSON格式化就是将原本难以阅读的JSON字符串转换为更具可读性的结构,便于我们理解数据的层次和关系,通常通过添加适当的缩进和换行来完成。

例如:
准备一段复杂的JSON数据:

"""
{"status":0,"msg":"success","data":[{"name":"印度","trend":{"updateDate":["4.7","4.8","4.9","4.10","4.11","4.12","4.13","4.14","4.15","4.16","4.17","4.18","4.19","4.20","4.21","4.22","4.23","4.24","4.25","4.26","4.27","4.28","4.29","4.30","5.1","5.2","5.3","5.4","5.5","5.6","5.7","5.8","5.9","5.10","5.11","5.12","5.13","5.14","5.15","5.16","5.17","5.18","5.19","5.20","5.21","5.22","5.23","5.24","5.25","5.26","5.27","5.28","5.29","5.30","5.31","6.1","6.2","6.3","6.4","6.5","6.6","6.7","6.8","6.9","6.10","6.11","6.12","6.13","6.14","6.15","6.16","6.17","6.18","6.19","6.20","6.21","6.22","6.23","6.24","6.25","6.26","6.27","6.28","6.29","6.30","7.1","7.2","7.3","7.4","7.5","7.6","7.7","7.8","7.9","7.10","7.11","7.12","7.13","7.14","7.15","7.16","7.17","7.18","7.19","7.20","7.21","7.22","7.23","7.24","7.25","7.26","7.27","7.28","7.29","7.30","7.31","8.1","8.2","8.3","8.4","8.5","8.6","8.7","8.8","8.9","8.10","8.11","8.12","8.13","8.14","8.15","8.16","8.17","8.18","8.19","8.20","8.21","8.22","8.23","8.24","8.25","8.26","8.27","8.28","8.29","8.30","8.31","9.1","9.2","9.3","9.4","9.5","9.6","9.7","9.8","9.9","9.10","9.11","9.12","9.13","9.14","9.15","9.16","9.17","9.18","9.19","9.20","9.21","9.22","9.23","9.24","9.25","9.26","9.27","9.28","9.29","9.30","10.1","10.2","10.3","10.4","10.5","10.6","10.7","10.8","10.9","10.10","10.11","10.12","10.13","10.14","10.15","10.16","10.17","10.18","10.19","10.20","10.21","10.22","10.23","10.24","10.25","10.26","10.27","10.28","10.29","10.30","10.31","11.1","11.2","11.3","11.4","11.5","11.6","11.7","11.8","11.9","11.10","11.11","11.12","11.13","11.14","11.15","11.16","11.17","11.18","11.19","11.20","11.21","11.22","11.23","11.24","11.25","11.26","11.27","11.28","11.29","11.30","12.1","12.2","12.3","12.4","12.5","12.6","12.7","12.8","12.9","12.10","12.11","12.12","12.13","12.14","12.15","12.16","12.17","12.18","12.19","12.20","12.21","12.22","12.23","12.24","12.25","12.26","12.27","12.28","12.29","12.30","12.31","1.1","1.2","1.3","1.4","1.5","1.6","1.7","1.8","1.9","1.10","1.11","1.12","1.13","1.14","1.15","1.16","1.17","1.18","1.19","1.20","1.21","1.22","1.23","1.24","1.25","1.26","1.27","1.28","1.29","1.30","1.31","2.1","2.2","2.3","2.4","2.5","2.6","2.7","2.8","2.9","2.10","2.11","2.12","2.13","2.14","2.15","2.16","2.17","2.18","2.19","2.20","2.21","2.22","2.23","2.24","2.25","2.26","2.27","2.28","3.1","3.2","3.3","3.4","3.5","3.6","3.7","3.8","3.9","3.10","3.11","3.12","3.13","3.14","3.15","3.16","3.17","3.18","3.19","3.20","3.21","3.22","3.23","3.24","3.25","3.26","3.27","3.28","3.29","3.30","3.31","4.1","4.2","4.3","4.4","4.5","4.6","4.7","4.8","4.9","4.10","4.11","4.12","4.13","4.14","4.15","4.16","4.17","4.18","4.19","4.20","4.21","4.22","4.23","4.24","4.25","4.26","4.27","4.28","4.29","4.30","5.1","5.2","5.3","5.4","5.5","5.6","5.7","5.8","5.9","5.10","5.11","5.12","5.13","5.14","5.15","5.16","5.17","5.18","5.19","5.20","5.21","5.22","5.23","5.24","5.25","5.26","5.27","5.28","5.29","5.30","5.31","6.1","6.2","6.3","6.4","6.5","6.6","6.7","6.8","6.9","6.10","6.11","6.12","6.13","6.14","6.15","6.16","6.17","6.18","6.19","6.20","6.21","6.22","6.23","6.24","6.25","6.26","6.27","6.28","6.29","6.30","7.1","7.2","7.3","7.4","7.5","7.6","7.7","7.8","7.9","7.10","7.11","7.12","7.13","7.14","7.15","7.16","7.17","7.18","7.19","7.20","7.21","7.22","7.23","7.24","7.25","7.26","7.27","7.28","7.29","7.30","7.31","8.1","8.2","8.3","8.4","8.5","8.6","8.7","8.8","8.9","8.10","8.11","8.12","8.13","8.14","8.15","8.16","8.17","8.18"],"list":[{"name":"确诊","data":[5480,5916,6725,7600,8446,9205,10453,11487,12322,13430,14352,15722,17615,18539,20080,21370,23039,24447,26283,27890,29451,31332,33062,34862,37257,39699,42505,46437,49400,52987,56351,59693,62808,67161,70768,74243,78055,81997,85784,90648,95698,100161,103292,107819,114478,124073,130506,137608,141228,150313,154820,163120,172359,180621,189765,194837,202860,214664,224215,233576,243733,254340,264143,273443,284754,297001,305951,317368,324482,336185,347821,359506,371734,385276,400724,421765,430708,449613,465553,481179,501864,527738,548154,562457,574926,593703,612486,633381,664488,687760,712920,739646,760761,790649,818647,847575,871499,898680,933450,959993,1001863,1036497,1055932,1106135,1127281,1171446,1220433,1263336,1323471,1383172,1424202,1466059,1529653,1579240,1601070,1690546,1749771,1780268,1830949,1901334,1958592,2021407,2057816,2129154,2199101,2244435,2322755,2372318,2431558,2506247,2530943,2634256,2684314,2732218,2814157,2873173,2925337,3038013,3079925,3149759,3211848,3286512,3377908,3454513,3477250,3583807,3649639,3715931,3810625,3904508,3993412,4092550,4160493,4236961,4313129,4417550,4494389,4606149,4688470,4788593,4878042,4963097,5060818,5141905,5228478,5323907,5417274,5517601,5580286,5669610,5765744,5843349,5915753,6041638,6087454,6156722,6245404,6323247,6438968,6509916,6573678,6650456,6724380,6764710,6841813,6946598,6997852,7063955,7160805,7205923,7275588,7349290,7416538,7475572,7536769,7574167,7644979,7701365,7727289,7781746,7829226,7873664,7918102,7974963,8006340,8070589,8094636,8178645,8208774,8250951,8305267,8352518,8380734,8439389,8478689,8531420,8576689,8601937,8659513,8690621,8751254,8790760,8837037,8867857,8886987,8925467,8974910,9021020,9065301,9129003,9170825,9193982,9245108,9291068,9308751,9393039,9432075,9463254,9484506,9523678,9556881,9593688,9625289,9667084,9689302,9714308,9756610,9780486,9814064,9844322,9881357,9902262,9925062,9933997,9966966,9987949,10015973,10047131,10067196,10094801,10111256,10141215,10157903,10178592,10208725,10224797,10237117,10260618,10282624,10293028,10310778,10337069,10345118,10369514,10388018,10405097,10426407,10448134,10460179,10473696,10485420,10497470,10525452,10540365,10556184,10566720,10572672,10582647,10606215,10619603,10634414,10645580,10661138,10672035,10689202,10690279,10702730,10720971,10740309,10750224,10764177,10768991,10788136,10799024,10805790,10816147,10831279,10846028,10848045,10859057,10878758,10880794,10894638,10910589,10919616,10931492,10942948,10956182,10969230,10989668,10997821,11008665,11028114,11043925,11056933,11077957,11094249,11102946,11121186,11136452,11152127,11171166,11190651,11204179,11228288,11241990,11260750,11266216,11287543,11327129,11353712,11382610,11404279,11410769,11473015,11509345,11551980,11590373,11607548,11682440,11726364,11780157,11794407,11860672,11965931,11990353,12089876,12110693,12203953,12229790,12319836,12476468,12508609,12625146,12732968,12847674,12978132,13164235,13261376,13444844,13564561,13714419,13960574,14268441,14465797,14732074,15040130,15239230,15609004,15924806,16257309,16519812,16869825,17116637,17519369,17867648,18368096,18754984,19157094,19549656,19919715,20275543,20658234,21070852,21485285,21886611,22295911,22662410,22991927,23340426,23702832,24046120,24372243,24683065,24964925,25227970,25495144,25771405,26030674,26285069,26528846,26751681,26947496,27156382,27367935,27547705,27719431,27893472,28046957,28173655,28306883,28440988,28572359,28693835,28808372,28909604,28996949,29088176,29182072,29273338,29358033,29424006,29507438,29570035,29632261,29699555,29761964,29822764,29881352,29934361,29973457,30027850,30082169,30133417,30182469,30232320,30278963,30316000,30361699,30410577,30453937,30501189,30544485,30584872,30618939,30662896,30708570,30743013,30794756,30836231,30873907,30904734,30944949,30986803,31025875,31063987,31105270,31141669,31153392,31209914,31219374,31289115,31297122,31341507,31396300,31417313,31470893,31490153,31528114,31579651,31619573,31693625,31708870,31732703,31809049,31815756,31884819,31902422,31944077,31981869,31998158,32052127,32077706,32117826,32190846,32205973,32249573,32279653,32295224]},{"name":"治愈","data":[468,506,620,774,969,1080,1181,1359,1432,1768,2041,2463,2854,3273,3975,4370,5012,5496,5939,6523,7137,7796,8437,9068,10007,10819,11775,12847,14142,15331,16776,17887,19301,20696,22549,24420,26400,27969,30234,34224,36795,38909,40458,43070,46002,50857,53947,54865,58727,63536,65944,69534,81606,84759,91016,93343,98113,103641,107419,112189,117404,122738,127991,131775,140033,146074,152395,159597,164803,172313,184243,190755,196894,208169,216730,235078,240289,254204,264542,277765,292626,308928,321178,329728,340225,353333,366027,383936,404351,417509,435441,454858,470144,483348,513503,532532,546379,566664,590219,609831,620194,651308,664461,693450,707523,737808,772488,800158,841424,883977,910298,936171,987174,1017204,1029069,1091018,1144277,1165442,1200303,1278084,1298528,1374420,1402076,1461772,1506413,1560800,1633356,1673885,1725834,1770682,1810079,1904612,1939454,2005215,2075836,2129764,2175492,2273973,2310922,2355823,2445975,2506724,2577990,2640121,2658419,2744887,2800671,2856147,2931005,3014685,3086545,3162305,3219750,3278999,3352316,3433604,3490908,3586216,3648534,3730949,3809549,3887371,3976413,4039986,4125742,4221471,4313402,4432630,4509924,4609704,4700625,4779658,4852313,4981099,5025815,5109584,5206044,5280204,5393737,5466344,5527934,5621193,5703607,5750403,5836826,5946371,6003244,6087588,6203130,6255622,6343270,6425716,6505179,6571659,6642698,6693491,6784742,6867988,6903365,6965699,7030903,7085242,7141966,7234749,7273649,7348147,7376961,7481951,7511472,7570044,7644926,7697460,7733477,7791363,7837061,7891991,7941094,7969954,8037467,8070817,8138948,8180967,8233765,8279822,8303358,8346331,8400113,8443553,8491462,8550931,8592303,8618445,8661421,8700681,8716566,8801161,8846313,8889585,8915158,8958524,8998066,9042308,9079888,9126233,9156423,9189704,9238188,9268492,9309031,9343056,9383735,9415086,9444229,9456552,9507421,9530530,9564162,9595711,9621683,9656883,9674090,9709469,9728747,9750670,9782669,9806767,9821119,9850394,9876557,9889946,9910982,9939466,9952548,9986904,10009404,10026751,10048922,10072016,10084011,10100053,10114980,10130451,10157879,10173747,10192158,10204340,10211342,10228753,10256410,10273553,10291077,10306666,10321966,10334850,10356476,10359305,10373649,10394352,10415080,10424619,10442137,10449858,10475872,10487650,10497654,10510807,10525343,10544069,10547201,10560593,10579622,10589230,10600905,10613072,10624838,10637743,10648633,10658469,10672253,10686299,10694193,10703460,10723130,10734328,10741483,10760379,10771400,10779954,10794590,10807877,10818721,10836798,10851094,10860512,10880059,10893442,10916916,10923264,10938146,10966735,10982516,11003784,11018816,11027543,11060390,11079697,11103681,11124465,11134333,11176854,11198515,11226705,11232919,11270831,11320418,11332289,11387270,11401824,11462934,11475836,11532137,11625318,11639575,11698657,11753169,11809277,11867486,11964985,12008162,12109473,12165126,12263113,12362012,12530565,12633314,12774046,12930733,13052362,13221039,13312271,13593113,13804309,14018818,14150962,14468946,14695983,14923460,15305026,15498680,15885993,16240047,16455477,16875349,17000610,17407470,17719749,18234220,18591134,18970018,19328365,19611259,19844129,20281508,20679456,21039370,21492926,21754130,22277260,22665206,23022025,23383307,23693992,23948435,24278735,24604894,24693493,25037378,25227740,25647332,25917521,25994295,26198172,26428307,26724010,26916989,27008777,27282022,27479472,27629621,27756262,27865723,27957446,28105369,28231022,28345261,28454938,28558214,28627998,28725030,28830037,28911454,28950726,29034224,29064502,29132853,29238048,29293497,29317068,29416815,29456404,29519131,29548302,29632032,29682688,29723553,29769484,29799534,29863463,29901927,29957090,30000214,30050975,30063720,30129597,30157396,30191151,30239521,30297377,30313050,30374508,30390687,30454757,30468079,30504747,30555315,30579106,30634202,30663147,30701612,30743972,30781263,30846509,30869454,30896354,30965030,30974748,31037245,31055861,31102724,31148536,31180968,31230332,31260050,31302345,31365316,31381493,31440221,31470067,31492285]},{"name":"死亡","data":[164,178,226,249,288,331,358,393,405,448,486,521,559,592,645,681,721,780,825,882,939,1008,1079,1154,1223,1323,1391,1566,1693,1785,1889,1985,2101,2212,2294,2415,2551,2649,2753,2871,3025,3144,3179,3317,3465,3707,3850,4004,4057,4334,4406,4653,4956,5144,5390,5577,5679,6028,6301,6440,6845,7117,7449,7558,7996,8473,8718,9109,9247,9590,10015,12029,12360,12677,13035,13502,13780,14162,14634,15042,15487,16088,16466,16797,17038,17521,17996,18320,18953,19568,20073,20618,21072,21586,22122,22659,23078,23569,24281,24865,25589,26267,26508,27428,27628,28488,29531,30122,31112,32082,32656,33129,34223,34948,35134,36497,37390,37690,38485,39787,40722,41627,42026,43144,44048,44855,46062,46717,47527,48888,49171,50845,51685,52280,53701,54438,55174,56792,57258,58317,59305,60267,61646,62669,62837,64062,64951,65725,66871,68059,69214,70519,71120,72033,73105,74367,75328,76744,77768,78931,80026,81168,82504,83433,84505,85731,86909,88231,89117,90282,91435,92587,93461,94971,95678,96468,97761,98822,100323,101211,101997,103005,104032,104651,105632,106925,107568,108412,109667,110118,110966,111726,112862,113578,114511,114902,115879,116585,117011,117474,118236,118621,119148,119823,120179,120899,121211,122099,122424,122848,123454,123955,124552,125263,125895,126370,126864,127170,127810,128204,128894,129357,129969,130391,130670,131130,131770,132310,132872,133589,134088,134383,134989,135533,135734,136733,137177,137659,137933,138467,138946,139473,139962,140481,140782,141078,141668,141977,142417,142841,143352,143667,143985,144144,144662,144914,145322,145669,146025,146414,146562,147029,147241,147521,147940,148190,148329,148660,148950,149095,149305,149603,149721,150028,150272,150470,150752,151000,151149,151265,151389,151578,151910,152068,152272,152369,152456,152593,152802,152947,153104,153316,153462,153525,153722,153751,153895,154047,154202,154358,154472,154547,154690,154782,154884,154966,155078,155158,155196,155286,155443,155489,155609,155734,155789,155883,155977,156090,156181,156325,156376,156457,156581,156713,156820,156947,157060,157125,157242,157360,157447,157562,157689,157750,157875,157949,158075,158123,158236,158418,158596,158750,158836,158902,159246,159387,159578,159728,159834,160181,160427,160642,160761,161049,161562,161730,162110,162237,162818,162993,163485,164610,164745,165293,165851,166426,167105,168203,168690,169651,170377,171205,172461,174171,175238,176745,178557,179795,181870,183088,186184,188630,191281,193055,196609,199388,202281,207215,209581,213997,218124,220571,225037,226720,231419,235189,242029,245057,249183,253470,256940,259479,264124,268521,273038,276947,279919,286063,290795,295047,298761,303355,305848,310416,314908,315869,320264,322982,328871,331607,332644,335489,338400,342280,346055,347259,350631,353246,355374,361010,364113,367577,371271,375185,377061,379601,382785,384275,385815,388096,389258,389661,391385,392123,393508,395715,396631,396972,398456,398913,399872,400434,401538,402359,403085,403700,404341,405425,406200,407537,408763,409267,409338,411928,412204,412720,413305,414113,414338,414657,418623,419471,419613,420196,420758,421117,421712,422175,422695,423403,423965,424777,425082,425388,426294,426434,427149,427565,428072,428577,428715,429564,429702,430285,431240,431558,432110,432421,432834]},{"name":"新增确诊","data":[533,565,809,875,846,759,1248,1034,835,1060,922,1370,1250,924,1541,1290,1669,1408,1836,1607,1561,1873,1738,1800,2394,2442,2806,3932,2963,3587,3364,3342,3113,4353,3607,3475,3763,3942,3787,4864,5050,4463,3131,4527,6659,9595,6433,7102,3620,9085,4507,8300,9239,8262,9144,5072,8023,11804,9551,9361,10157,10607,9803,9300,11311,12247,8950,11417,7114,11703,11636,11685,12228,13542,15448,21041,8943,18905,15940,15626,20685,25874,20416,14303,12469,18777,18783,20895,31107,23272,25160,26726,21115,29888,27998,28928,23924,27181,34770,26543,41870,34634,37407,50203,36810,44165,48987,42903,60135,59701,41030,41857,63594,49587,54966,57704,59225,52783,50681,70385,57258,62815,61455,71338,69947,45334,78320,49563,59240,74689,24696,103313,50058,47904,81939,59016,52164,112676,41912,69834,62089,74664,91396,76605,22737,106557,65832,66292,94694,93883,88904,99138,67943,76468,76168,104421,76839,111760,82321,100123,89449,85055,97721,81087,86573,95429,93367,100327,62685,89324,96134,77605,72404,125885,45816,69268,88682,77843,115721,70948,63762,76778,73924,40330,77103,104785,51254,66103,96850,45118,69665,73702,67248,59034,61197,37398,70812,56386,25924,54457,47480,44438,44438,56861,31377,64249,24047,84009,30129,42177,54316,47251,28216,58655,39300,52731,45269,25248,57576,31108,60633,39506,46277,30820,19130,38480,49443,46110,44281,63702,41822,23157,51126,45960,17683,84288,39036,42098,21252,39172,33203,36807,31601,41795,22218,25006,42302,23876,33578,30258,37035,20905,22800,8935,32969,20983,28024,31158,20065,27605,16455,29959,16688,20689,30133,16072,12320,23501,22006,10404,17750,26291,8049,24396,18504,17079,21310,21727,12045,13517,11724,12050,27982,14913,15819,10536,5952,9975,23568,13388,14811,11166,15558,10897,17167,1077,12451,18241,19338,9915,13953,4814,19145,10888,6766,10357,15132,14749,2017,11012,19701,2036,13844,15951,9027,11876,11456,13234,13048,20438,8153,10844,19449,15811,13008,21024,16292,8697,18240,15266,15675,19039,19485,13528,24109,13702,18760,5466,21327,39586,26583,28898,21669,6490,62246,36330,42635,38393,17175,74892,43924,53793,14250,66265,105259,24422,99523,20817,93260,25837,90046,156632,32141,116537,107822,114706,130458,186103,97141,183468,119717,149858,246155,307867,197356,266277,308056,199100,288956,315802,332503,326769,350013,246812,402732,348279,307219,386888,402110,392562,370059,355828,382691,412618,414433,401326,409300,366499,329517,348499,362406,343288,326123,310822,281860,263045,267174,276261,259269,254395,243777,222835,195815,208886,211553,179770,171726,174041,153485,126698,133228,134105,131371,121476,114537,101232,87345,91227,93896,91266,84695,65973,68400,62597,62226,67294,62409,60800,58588,53009,39096,54393,54319,51248,49052,49851,46643,37037,45699,48878,43360,47252,43296,40387,34067,43957,45674,34443,42648,41475,37676,30827,40215,67344,39072,38112,41283,36399,11723,56522,9460,69741,8007,44385,54793,21013,53580,19260,37961,51537,39922,74052,15245,23833,76346,6707,69063,17603,41655,37792,16289,53969,25579,40120,73020,15127,43600,30080,15571]}]}}]}
"""

①JSONLint
JSONLint网站:https://jsonlint.com/
在这里插入图片描述
格式化后的数据:
在这里插入图片描述
②JSON Formatter & Validator
JSON Formatter & Validator网站:https://jsonformatter.curiousconcept.com/#

格式化后的数据:
在这里插入图片描述
③JSON Editor Online
JSON Editor Online网站:https://jsoneditoronline.org/#left=local.hejeki
在这里插入图片描述
格式化后的数据:
在这里插入图片描述
④ab173
ab173网站:http://www.ab173.com
该网站提供了快速查看和格式化 JSON 数据的在线工具。用户可以将 JSON 数据粘贴到网站上,以便查看其结构、格式化和调试,帮助用户浏览复杂的 JSON 数据,以理解其层级和内容。
在这里插入图片描述
粘贴标准的 JSON 数据并点击格式化。
在这里插入图片描述
格式化后的JSON数据:
在这里插入图片描述

点击左上角的视图,在视图界面中我们可以折叠和展开格式化后的 JSON 数据,便于查看更深层的数据结构。
在这里插入图片描述
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1962227.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【大模型系列篇】Vanna-ai基于检索增强(RAG)的sql生成框架

简介 Vanna是基于检索增强(RAG)的sql生成框架 Vanna 使用一种称为 LLM&#xff08;大型语言模型&#xff09;的生成式人工智能。简而言之&#xff0c;这些模型是在大量数据&#xff08;包括一堆在线可用的 SQL 查询&#xff09;上进行训练的&#xff0c;并通过预测响应提示中最…

中间件安全:Nginx 解析漏洞测试.

中间件安全&#xff1a;Nginx 解析漏洞测试. Nginx 是一个高性能的 HTTP和 反向代理服务器&#xff0c;Nginx 解析漏洞是一个由于配置不当导致的安全问题&#xff0c;它不依赖于Nginx或PHP的特定版本&#xff0c;而是由于用户配置错误造成的。这个漏洞允许攻击者上传看似无害的…

通俗易懂,车载显示屏简单介绍!

2024年后&#xff0c;小汽车产量的年增长率预计将在1%至3%之间 2023年在COVID完全解封后&#xff0c;全球汽车销售数量提升至8千8百万台车。2024预估微幅增加到 9000万辆&#xff0c; 自2024起&#xff0c;年成长率预期将放缓至3%以下。全球汽车主要销售前三大市场 (比较2022年…

为什么阿里开发手册不建议使用Date类?

在日常编码中&#xff0c;基本上99%的项目都会有一个DateUtil工具类&#xff0c;而时间工具类里用的最多的就是java.util.Date。 大家都这么写&#xff0c;这还能有问题&#xff1f;&#xff1f; 当你的“默认常识”出现问题&#xff0c;这个打击&#xff0c;就是毁灭性的。 …

BUG解决(vue3+echart报错):Cannot read properties of undefined (reading ‘type‘)

这是 vue3echart5 遇到的报错&#xff1a;Cannot read properties of undefined (reading ‘type‘) 这个问题需要搞清楚两个关键方法&#xff1a; toRaw&#xff1a; 作用&#xff1a;将一个由reactive生成的响应式对象转为普通对象。 使用场景&#xff1a; 用于读取响应式…

idea2023 总报Low memory

idea2023 总报Low memory 问题背景问题处理 问题背景 在日常开发中&#xff0c;使用idea2023开发工具&#xff0c;开发过程中总会遇到idea提示Low memory的情况&#xff0c;并且每当提示出现的时候&#xff0c;整个idea页面便什么也不能操作了&#xff0c;如何处理这个情况呢&…

AI测试:人工智能模型的核心测试指标,分类判别、目标检测、图像分割、定量计算分别有哪些指标?

在前面的人工智能测试技术系列文章中&#xff0c;我们详细介绍了人工智能测试的技术方法和实践流程。在了解人工智能测试方法后&#xff0c;我们需要进一步学习和研究如何衡量这些方法的有效性&#xff0c;即人工智能模型测试指标的选择。测试指标的选择主要取决于模型的类型和…

借助大语言模型快速升级你的 Java 应用程序

大家都知道我爱小 Q。在我“转码”的征程中&#xff0c;它就像上帝之手&#xff0c;在我本该枯燥漫长的学习进程中拉满快进条。 不仅是我&#xff0c;最近 Amazon Q Developer 还帮助 Amazon 一个由 5 人组成的团队在短短两天内将 1,000 多个生产应用程序从 Java 8 升级到 Jav…

Spring Cloud 组件

1.eureka注册中心原理简述 1.服务注册: Eureka Client 会通过发送rest请求的方式向eureka服务端注册自身元数据:ip地址,端口,运行状况等信息,服务端会把注册信息存储在一个双层map中。 Eureka 的数据存储分了两层&#xff1a;数据存储层和缓存层。 Eureka Client 在拉取服务信息…

【STM32嵌入式系统设计与开发拓展】——13_PWM脉宽

目录 1、什么是PWM?用来做什么的&#xff1f;PWM&#xff08;Pulse Width Modulation&#xff09;脉冲宽度调制常见用到 PWM 的情况&#xff1a; 2、什么是输出比较&#xff1f;输出比较模式![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/42434920ca0940b1b1083215…

vue el-input 输入框下拉显示匹配数据

1、效果图&#xff1a; 2、需求&实现&#xff1a; 输入条件 下面匹配查询到的数据有多少个 需要调用后端接口展示&#xff0c;后端查询到之后返回条数 前端展示 3、具体代码实现&#xff1a; html&#xff1a; 图片需要自己根据实际情况增加 // 查询 重置 筛选 本文章…

【git】git常用命令提交规范

Git 是程序员工作中不可或缺的版本控制工具&#xff0c;以下是一些优化后的常用 Git 命令列表&#xff0c;旨在帮助你更高效地使用 Git 进行版本控制。 基础操作 拉取代码 git clone xxx.git创建分支 git branch dev切换分支 git checkout dev # 或者 git switch dev创建并切换…

Python酷库之旅-第三方库Pandas(056)

目录 一、用法精讲 211、pandas.Series.truncate方法 211-1、语法 211-2、参数 211-3、功能 211-4、返回值 211-5、说明 211-6、用法 211-6-1、数据准备 211-6-2、代码示例 211-6-3、结果输出 212、pandas.Series.where方法 212-1、语法 212-2、参数 212-3、功能…

论报文加密加签场景下如何高效的进行渗透测试

前言 最新的测试中&#xff0c;经常遇到HTTP报文加密/加签传输的情况&#xff0c;这导致想要查看和修改明文报文很不方便。 之前应对这种情况我们有几种常见的办法解决&#xff0c;比如使用burpy插件、在Burp上下游使用mitmproxy进行代理等&#xff0c;但这些使用起来不太方便…

LSTM详解总结

LSTM&#xff08;Long Short-Term Memory&#xff09;是一种用于处理和预测时间序列数据的递归神经网络&#xff08;RNN&#xff09;的改进版本。其设计初衷是为了解决普通RNN在长序列训练中出现的梯度消失和梯度爆炸问题。以下是对LSTM的详细解释&#xff0c;包括原理、公式、…

面向非结构化数据的知迟抽取

文章目录 实体抽取关系抽取事件抽取大量的数据以非结构化数据(即自由文本)的形式存在,如新闻报道、科技文献和政府文件等,面向文本数据的知识抽取一直是广受关注的问题。在前文介绍的知识抽取领域的评测竞赛中,评测数据大多属于非结构化文本数据。本节将对这一类知识抽取技…

Prometheus-部署

Prometheus-部署 Server端安装配置部署Node Exporters监控系统指标监控MySQL数据库监控nginx安装grafana Server端安装配置 1、上传安装包&#xff0c;并解压 cd /opt/ tar xf prometheus-2.30.3.linux-amd64.tar.gz mv prometheus-2.30.3.linux-amd64 /usr/local/prometheus…

【音频识别】十大数据集合集,宝藏合集,不容错过!

本文将为您介绍10个经典、热门的数据集&#xff0c;希望对您在选择适合的数据集时有所帮助。 1 RenderMe-360 发布方&#xff1a; 上海人工智能实验室 发布时间&#xff1a; 2023-05-24 简介&#xff1a; RenFace是一个大规模多视角人脸高清视频数据集&#xff0c;包含多样的…

2024年最强网络安全学习路线,详细到直接上清华的教材!

关键词&#xff1a;网络安全入门、渗透测试学习、零基础学安全、网络安全学习路线 首先咱们聊聊&#xff0c;学习网络安全方向通常会有哪些问题前排提示&#xff1a;文末有CSDN官方认证Python入门资料包 &#xff01; 1、打基础时间太长 学基础花费很长时间&#xff0c;光语…

Redis内存管理

文章目录 Redis内存管理删除策略淘汰策略LRU算法 Redis内存管理 长期把Redis做缓存用&#xff0c;总有一天Redis内存总会满的。有没有思考过这个问题&#xff0c;Redis内存满了会怎么样&#xff1f;在redis.conf中把Redis内存设置为1个字节&#xff0c;做一个测试&#xff1a;…