decode: concentrate JSON formatting in a single location
It's incredible how a single arbitrary choice of not supporting trailing
commas complicates generator code which immediately writes its output,
instead of accumulating pieces and separating but not terminating them
before transmitting the result.
Concentrate all text to open and close the file and array items, as well
as to separate the array item fields, in the jsontrace_open_close()
routine. This makes calling code more verbose, but heavily simplifies
the sequence and allows to shuffle items without unnecessary manual
adjustment of formatting details. Added complexity to make some of the
closing calls optional also helps.
When this DIY code is considered unmaintainable, the alternative is to
introduce another dependency on a JSON library.