templatefilters: defend against evil unicode strs in json filter
We only want to do I/O in terms of bytes, so lets explode early
instead of recursing forever.
Differential Revision: https://phab.mercurial-scm.org/D1136
#require docutils gettext $ $TESTDIR/check-gendoc da checking for parse errors