# -*- coding: utf-8 -*- # @File : json_infoShow.py # @Author : zhaoHL # @Contact : huilin16@qq.com # @Time Create First: 2021/8/1 10:25 # @Contributor : zhaoHL # @Time Modify Last : 2021/8/1 10:25 ''' @File Description: # 输出json文件基本信息 !python ./json_infoShow.py \ --json_path=./input/instances_val2017.json ''' import json import argparse def js_show(js_path, show_num): print('Info'.center(100,'-')) print('json read...') with open(js_path, 'r') as load_f: data = json.load(load_f) print('json keys:',data.keys(),'\n') for k, v in data.items(): print(k.center(50, '*')) show_num_t = show_num if len(v)>show_num else len(v) if isinstance(v, list): print(' Content Type: list\n Total Length: %d\n First %d record:\n'%(len(v),show_num_t)) for i in range(show_num_t): print(v[i]) elif isinstance(v, dict): print(' Content Type: dict\n Total Length: %d\n First %d record:\n'%(len(v),show_num_t)) for i,(kv,vv) in enumerate(v.items()): if i