Add CSRF-protection to writeJSON by default

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