Allow JSON.stringify customization

Closes #1119