Add profiling stuff for as_json and JSON.generate