Common resources - How to Escape the Values of an Array of Objects Containing Special Characters

When using custom Javascript code to build a Common resource field that references different values mapped in the transformation, the JSON.stringify should be referenced when joining the mapped values. Utilizing this tool escapes any illegal or special characters that might appear when the vendor sends out data and results in a valid data set. 


return JSON.stringify(elements.join(', '));