Added code for exporting to JSON.