def json_get(file): keys = list(map(lambda key: key.split("."), args.keys)) for json in load(file): if keys: for subkeys in keys: try: print(dumps(reduce(lambda get, subkey: get[subkey], subkeys, json), indent = indent)) except: pass else: print(dumps(json, indent = indent))
def json_remove(file): keys = list(map(lambda key: key.split("."), args.keys)) for json in load(file): for subkeys in keys: try: remove = json last_index = len(subkeys) - 1 for i in range(last_index): remove = remove[subkeys[i]] del remove[subkeys[last_index]] except: pass print(dumps(json, indent=indent))
def json_remove(file): keys = list(map(lambda key: key.split("."), args.keys)) for json in load(file): for subkeys in keys: try: remove = json last_index = len(subkeys) - 1 for i in range(last_index): remove = remove[subkeys[i]] del remove[subkeys[last_index]] except: pass print(dumps(json, indent = indent))
def json_put(file): subkeys = args.key.split(".") value = args.value last_index = len(subkeys) - 1 last_subkey = subkeys[last_index] for json in load(file): try: put = json for i in range(last_index): put = put[subkeys[i]] put[last_subkey] = value except: pass print(dumps(json, indent=indent))
def json_get(file): keys = list(map(lambda key: key.split("."), args.keys)) for json in load(file): if keys: for subkeys in keys: try: print( dumps(reduce(lambda get, subkey: get[subkey], subkeys, json), indent=indent)) except: pass else: print(dumps(json, indent=indent))
def json_put(file): subkeys = args.key.split(".") value = args.value last_index = len(subkeys) - 1 last_subkey = subkeys[last_index] for json in load(file): try: put = json for i in range(last_index): put = put[subkeys[i]] put[last_subkey] = value except: pass print(dumps(json, indent = indent))