json提取器

json-extract的Python项目详细描述


PyPI - Python Version

安装 json_extract

pip install json-extract

{"animals":{"zoon":[{"name":"Peki","sex":"girl","age":18},{"name":"George","sex":"boy","type":"zoon"}],"people":[{"name":"Rufus","sex":"girl","weight":"88"},{"name":"Marty","sex":"boy","people":[{"name":"Rufus","type":"people",},{"name":"Marty","sex":"???","age":"10"}]}]}}
response_json={}fromjson_extractimportGetValue2getobj=GetValue2(response_json)sex=getobj.get_values('sex')print(sex)# ['girl', 'boy', 'girl', 'boy']deep=getobj.get_values("sex",deep=True)# ['girl', 'boy', 'girl', 'boy', '???']filte=getobj.get_values("sex",filters=True)# ['girl', 'boy']notexiste=getobj.get_values("asdfadfs",default='not existe')# orgetobj.get_values("asdfadfs",'not existe')# not existeweight=getobj.get_values("weight")# 88weight_shell=getobj.get_values("weight",shell=True)# ['88']age=getobj.get_values("age")# [18, '10']age_int=getobj.get_values('age',ret_type=int)# [18, 10]age_str=getobj.get_values("age",ret_type=str)# ['18', '10']
        :param key: Key value to be resolved 需要解析的key值
        :param default: If the result is empty, the default value is none  如果结果为空 备用值 默认None
        :param deep: Do you want to deeply resolve all keys? Default false 是否深度解析所有key 默认False
        :param filters: Whether to de duplicate the result, the default is false 是否去重结果 默认False
        :param shell: If the result is whether to remove the outer list shell, the default is false 如果结果为一个 是否去掉外面list壳子 默认False(去壳)
        :param ret_type: The return result type can pass in 'int' or 'str' by default  返回结果类型 可传入'int'或'str' 默认原始

End

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

推荐PyPI第三方库


热门话题
java创建猜谜游戏程序   JavaWebSocketContainer。connectToServer似乎挂起了   如何在java中中断函数   java c#socket client multiple BeginSend()未到达服务器   不可见的组件然后在Java中的窗格之间切换   java在应用程序类中使用静态接口安全吗?   java等待函数完成,直到回调到来   使用DataOutputStream时的java新行,Android   java服务对象的定义是什么?   基于视图的javahibernate复合密钥   java将varchar连接到char在JPA(oracle)中不起作用   如何在java中通过point类读取多个点?