Properly escape backslashes when generating JSON on the server.