当前位置:网站首页>唯品会工作实践 : Json的deserialization应用
唯品会工作实践 : Json的deserialization应用
2022-06-26 08:30:00 【冯大少】
JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,它是JavaScript的子集,易于人阅读和编写。主要有两种常见类型结构,Key_Value对的集合和值的有序列表,分别对应 Python 里的字典和列表。
JSON 的常用方法主要有以下这些:

以下通过在唯品会的工作实践,演示Json的deserialization应用。打开其中一个链接,可见主要是通过 API(Application Programming Interface)加载数据。在 Request URL中,?后面是一堆好像外星文的内容,这些都是查询字符串。以键值对 key=value 的形式赋值,多个键值对之间用 & 连接在一起。查询字符串用于信息的传递,服务器通过它就能知道你想要什么,从而给你返回对应的内容。

首先尝试获取网页源代码数据,然后尝试通过 json() 方法对响应内容解码,结果却遇到解码报错提示。

在 " Preview" 可见,并不是 Json数据格式。

首先用 replace() 方法 把 ‘getMerchandiseDroplets1(’ 和 ‘)’ 删除,然后通过 json.loads() 方法,反序列化后,成功转换成Python的数据对象 - dict



加入循环,可以利用dict取值,打印出所有相关的产品名。
for i in range(33):
print(str1_json[‘data’][‘products’][i][‘title’])

边栏推荐
- STM32 project design: temperature, humidity and air quality alarm, sharing source code and PCB
- How to correctly PIP install pyscipopt
- STM32 project design: smart home system design based on stm32
- Use a switch to control the lighting and extinguishing of LEP lamp
- Record the problem yaml file contains Chinese message 'GBK' error
- Implementation of ffmpeg audio and video player
- Speckle denoising method for ultrasonic image
- Installation of jupyter
- Apple motherboard decoding chip, lightning Apple motherboard decoding I.C
- ROS learning notes (6) -- function package encapsulated into Library and called
猜你喜欢

OpenCV Learning notes iii

(5) Matrix key

Clion installation + MinGW configuration + opencv installation

Compiling owncloud client on win10

2020-10-17
![[unity mirror] use of networkteam](/img/b8/93f55d11ea4ce2c86df01a9b03b7e7.png)
[unity mirror] use of networkteam

鲸会务一站式智能会议系统帮助主办方实现数字化会议管理

(4) Independent key

Euler function: find the number of numbers less than or equal to N and coprime with n

STM32 project design: an e-reader making tutorial based on stm32f4
随机推荐
GHUnit: Unit Testing Objective-C for the iPhone
Addition of attention function in yolov5
2020-10-29
Ultrasonic image segmentation
Speckle denoising method for ultrasonic image
Detailed explanation of self attention & transformer
Bezier curve learning
Matlab drawing checkerboard (camera calibration)
What are the conditions for Mitsubishi PLC to realize Ethernet wireless communication?
1.21 study gradient descent and normal equation
Nebula diagram_ Object detection and measurement_ nanyangjx
ROS learning notes (5) -- Exploration of customized messages
Exploration of webots and ROS joint simulation (II): model import
nn. Modulelist and nn Sequential
opencv学习笔记二
在 KubeSphere 部署 Wiki 系统 wiki.js 并启用中文全文检索
Drawing with MATLAB (1)
Fourier transform of image
(4) Independent key
And are two numbers of S