All of these strings cannot be printed bare to the output but need to be encoded in the appropriate way for JSON strings - otherwise the resulting file will be corrupt. Given this is a JS file the cheapest way to do this would be to call JSON.stringify on them