8 parser = argparse.ArgumentParser(
9 description="""Extracts information from a json file by navigating the JSON object using a
10 sequence of property accessors and returning the JSON subtree, or the raw data, found
16 metavar='<project.json>',
17 help="Path to project.json file to parse",
23 metavar='property_name',
24 help="""Name of property to extract using object notation.
25 Pass multiple values to drill down into nested objects (in order).""",
31 help="""Dumps the raw object found at the requested location.
32 If omitted, returns a JSON formatted object instead.""",
37 return parser.parse_args()
42 with open(args.file) as json_file:
43 selected_property = json.load(json_file)
45 for prop in args.property:
46 selected_property = selected_property[prop]
49 print(selected_property)
51 print(json.dumps(selected_property))
55 if __name__ == "__main__":