I’m creating a CEP panel in After Effects, composed of various input text fields. Simply put, upon pressing a button, all the text strings are collected into an object and then sent to ExtendScript to be displayed in an alert. In ExtendScript, the parsing of the string sent from the CEP panel works fine until special characters are used. For example, if I write ‘text’s’, the apostrophe creates an error and the parsing doesn’t work. I can’t figure out how to handle these behaviors escaping the strings or using other approaches. Here a piece of code. thank you
//javascript
function (sendObjtoExtendscript){
var myObj = {
text1 : "test",
text2 : "test's"
};
var csInterface = new CSInterface();
csInterface.evalScript("myFunction('"+JSON.stringify(myObj)+"')");
};
//extendscript
// in the line 1, the json2.js library
function myFunction(value){
var x = JSON.parse(value);
alert(x.text2);
}
//result: Unable to execute script at line 1. Expected: )
I need to get the exact strings from the input texts, so in the panel, if I type “Joe’s” I want to see it in the extendscript alert message.
1