Use `JSON.stringify` instead of manually escaping strings

* The `\b` regex was causing problems, and `JSON.stringify` handles it
  *and* the unicode characters which originally caused issues, and
  probably some other characters we don't handle also.
Merge pull request #1337 from reciprocity/feature/fix-json-escaping

Use `JSON.stringify` instead of manually escaping strings