当前位置:网站首页>【记录】把json的所有key转换成小写
【记录】把json的所有key转换成小写
2022-08-03 05:26:00 【IT界的测试混子】
import json
d = '''{ "Type": "Abc", "Id": "NO_ID", "IntId": -1, "Hashcode": 54321, "Rect": { "Width": 1234, "Height": 222, "Left": 0, "Top": 0 }, "Visible": true, "Enabled": true, "Clickable": false, "Tag": "", "Desc": "", "Children": [ { "Type": "android.widget.LinearLayout", "Id": "NO_ID", "IntId": -1, "Hashcode": 12345, "Rect": { "Width": 1234, "Height": 2220, "Left": 0, "Top": 0 }, "Visible": true, "Enabled": true, "Clickable": false, "Tag": "", "Desc": "", "Children": [ { "Type": "android.view.ViewStub", "Id": "01234", "IntId": 2314, "Hashcode": 22222, "Rect": { "Width": 0, "Height": 0, "Left": 0, "Top": 0 }, "Visible": false, "Enabled": true, "Clickable": false, "Tag": "", "Desc": "", "Children": [] } ] } ] }'''
def change_key_lower(d):
if isinstance(d,dict):
for i in list(d.keys()):
if isinstance(d[i], dict):
change_key_lower(d[i])
if isinstance(d[i],list):
for j in d[i]:
if isinstance(j, dict):
change_key_lower(j)
d[i.lower()] = d.pop(i)
if __name__ == '__main__':
d = json.loads(d)
res = change_key_lower(d)
边栏推荐
猜你喜欢

数组与字符串15-最大连续1的个数

002_旭日X3派初探:TogetherROS安装

802.1AS 延迟测量理解

数组与字符串10-实现 strStr()

VS2022 encapsulates static libraries and calls static libraries under window

Delightful Nuxt3 Tutorial (2): Build a Blog Quickly and Easily

mib browser无法接收snmp trap消息解决

电子元器件和电子元件的区别有那些?

SolidWorks 操作视频 | 流体分析结果演示

9. Please introduce the class loading process, what is the parent delegation model?
随机推荐
二分查找4 - 搜索旋转排序数组
VS2022 encapsulation under Windows dynamic library and dynamic library calls
申请公网ip后,配置光猫,路由器使用公网ip步骤
pandoc -crossref插件实现markdwon文档转word后公式编号自定义
常见的电子元器件分类介绍-唯样商城
电子元器件和电子元件的区别有那些?
3D游戏建模师在国内的真实现状,想转行,先来看看!
使用Blender和ZBrush制作武器模型
A.1#【内存管理】——1.1.2 zone: struct zone
ZEMAX | 在设计抬头显示器(HUD)时需要使用哪些工具?
MATLAB给多组条形图添加误差棒
memblock
3D建模:做什么副业在家就能月入1W?
树——前序
ZEMAX | How to rotate any element around any point in space
八、抽象类的接口的区别
Typora
游戏3D建模师是吃青春饭的吗?被高薪挖掘的建模人才,靠的是这个
ue4入门学习笔记1(操作界面)
二分查找3 - 猜数字大小