Add by-default CSRF-protection to writeJSON

Added two extra functions, writeJSONWrapped, and writeJSONUnprotected.
The original writeJSON is renamed to writeJSONUnprotected
writeJSON prefixes with ")]}',\n" which is stripped away by AngularJS
by default.
writeJSONWrapped can wrap with a specific wrapper