more elaborate documentation, and option to preserve whitespace in toJSON()