add JSON output format

I would like to use this script to dump data in JSON format for use in MongoDB.