Implement for_json kwarg; pure Python version; add tests; update documentation.