This gets a leetle complicated, but does give us the output in a format acceptable for Python's json parser