I have a unique challenge where I need to output some Javascript code on the browser screen for easy transfer to another program.
Currently, I am utilizing JSON.stringify()
from the json2.js
library. However, this method is not correctly escaping characters such as quotes and new lines (",\n) which are crucial parts of a JSON object.
An issue arises when importing into another program due to problematic strings like the following:
{
string_property_01 : "He said "HI""; // The string terminates after "He said "
}
Does anyone know of any libraries that can efficiently escape all necessary characters in this scenario?
Thank you!