Skip to content

Instantly share code, notes, and snippets.

@simonc
Created April 16, 2021 14:52
Show Gist options
  • Save simonc/b3515b2f0e97d9a7a5fc1647e7886264 to your computer and use it in GitHub Desktop.
Save simonc/b3515b2f0e97d9a7a5fc1647e7886264 to your computer and use it in GitHub Desktop.
Code by Zapier - JavaScript code to clean data for JSON
let data = Object.assign({}, inputData);
for (let key in data) {
if (typeof(data[key]) === "string" && data[key].length > 0) {
data[key] = data[key].replace(/\r?\n/g, "<br>").replace(/\t/g, " ").replace(/"/g, '\\\"');
}
}
output = [data];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment