Change JSON output format

The new format lists spans and edges connecting them explicitly, rather
than in a recursive data structure.