Use JSON.generate instead of #to_json

Closes #73.