In the end I made a python script that converts petra reports into
json. It so petra.py can be used as a library:
        petra_rep = petra.Report(path_to_report=path_to_report)
	# or petra_rep = petra.Report(pr=report_string)
	print(petra_rep.ending_balance)

Or it can be used as a script in a pipeline:
petra.py path_to_report | grep 'ending_balance'

or can translate petra reports into json files:
petra.py path_to_report path_to_output_json