from collections.abc import Iterable import os import sys import json j = blob = json.load(sys.stdin) new = {} for k, v in blob.items(): new[k] = v["value"] new = {"all": {"vars": new}} json.dump(new, fp=sys.stdout, indent=2)