OL Learn

NodeJS Server Input Encoding issue

As @Phil suggested, I am trying to restructure our web applications to get around the CORS issues raised here:CORS Policy for OLConnect Server 2021.1

As part of the application, I am using a load external file to load a json file which is encoded in UTF-8

Then I am using the below script to dynamically set the values of a couple of fields before writting the result back to the job file which will be a response to an ajax call from my Connect template.

var json_model = JSON.parse(Watch.ExpandString("%c"));
json_model.logo = Watch.GetVariable(“global.base_url”) + ‘/_iRes/logos/’ + Watch.GetVariable(“customer_name”) + ‘.png’;
/* Write the data to the Job Data File */
var stream = new ActiveXObject(‘ADODB.Stream’);
stream.Type = 2;
stream.Mode = 3;
stream.Charset = “UTF-8”;
stream.WriteText(JSON.stringify(json_model) );

In the response JSON received from Workflow, I have lost all special characters àáãäâèéëêìíïîòóöôùúüûñç and others from turkish, swedish and norvegian languages. A problem I didn’t have when I was loading my json whithout using a workflow process.


How can I preserve the accents and other special characters that are inside the original UTF-8 JSON?

Hi Rob,

I’d advise using the translator plugin to convert fro9m UTF 8 into the specific ANSI table you need this may not work or need additional logic if your working with multi[le languages in one file.



It seems that this is standard behaviour when you use JSON.stringify. Because the characters are replaced with unicode characters by using this function in a Run Script plugin (language: JScript). Unfortunately I couldn’t find a solution how to avoid this. Maybe you can convert the JSON object to a string by making use of a custom function.

Run Script plugin:

var obj = {
    test: "àáãäâèéëêìíïîòóöôùúüûñç"

Watch.Log(JSON.stringify(obj), 3);


[0002] Starting plugin Run Script - 11:05:52
[0002] Run embedded script...
[0002] {"test":"\u00e0\u00e1\u00e3\u00e4\u00e2\u00e8\u00e9\u00eb\u00ea\u00ec\u00ed\u00ef\u00ee\u00f2\u00f3\u00f6\u00f4\u00f9\u00fa\u00fc\u00fb\u00f1\u00e7"}
[0002] Data file processed : debug2EFB437.dat, size: 63 bytes
[0002] Plugin Run Script completed successfully - 11:05:52 (elapsed time: 00:00:00.001)