In json code, clean up temp memory contexts after processing.

Craig Ringer.