Fix incorrect characters in json error message.
Add escaping non-JSON characters consistently.
Add a new method escapeForJSON in tools module for this.
sendError() now escape consistently.