更容易遍历和探索json结构

ez-json-traverse的Python项目详细描述


ez-json遍历Build StatusSupported Python VersionLicense

更容易遍历和探索json结构。

提供可遍历序列EZJL、可遍历映射EZJD和方便的方法,如as_traversable

出发

$ pip install ez-json-traverse

后跟

fromezjtimportas_traversable

口述材料

d={'a':{'name':'Jane','age':{'unit':'year','value':12}},'b':{'name':'John','age':{'unit':'year','value':14}},'c':{'name':'Jill','age':{'unit':'year','value':10}}}t=as_traversable(d,sep='.',map_char='^')# EZJD# Normal key accesst['a']# EZJD of {'name': 'Jane', 'age': {'unit': 'year', 'value': 12}}# Path key accesst['a.name']# 'Jane'# Mapping across valuest['^.age.value']# EZJD of [12, 14, 10]

列出资料

l=[[0,[1,2]],[1,[2,3]],[2,[3,4]]]t=as_traversable(l,sep='.',map_char='^')# EZJL# Normal key accesst[0]# EZJL of [0, [1, 2]]t['0']# EZJL of [0, [1, 2]]# Path key accesst['0.1.0']# 1# Mapping across valuest[':^.1.0']# EZJL of [1, 2, 3]t['1:-1^.1.0']# EZJL of [2] 

其他便利设施

t=as_traversable(...,sep='.',map_char='^')# EZJLt.parent# Parent containert.root# Root containert.path# Path from root container to current traversablet.key# Final key or index of current traversable

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java从提供的列表中获取非重复值   java为什么Thymeleaf从HashMap返回字符串?   java将矩阵推到窗口的中心   java如何包含webapp_配置。txt到播放的dist-zip?   java实现产品密钥   WebSphereJava。lang.UnsupportedClassVersionError:JVMCFRE003错误的主要版本;class=org/slf4j/impl/StaticLoggerBinder,偏移量=6   使用java创建动态树结构   java为什么JVM在一次繁忙的旋转暂停后,会对同一代码块显示更多的延迟?   java无法使用distrolessdebug访问jarfile docker   java JMeter如何将多行响应数据传递给ForEach控制器请求   java空指针异常碎片活动   java改变JFileChooser的外观   性能Java位集:高效地查找所有真实位?   java可扩展的recyclerview实现