Microsoft JScript compilation error when executing Process function

Hi, I'm trying to add a new data source to AmiQuote. The data is in JSON format, so I'm using Javascript to parse the JSON to CSV format.
I verified the code in both IE and Chrome. They both worked very well.
Somehow when I paste the code into AmiQuote and click the Request button under Debug tab. It throws an error: Script error 0, Expected ';', Microsoft JScript compilation error.
here is my code:

function Process( input )
{
	var csv = '';
	var arr = JSON.parse(input);
	for(line of arr) {
		csv += line.date + "," + line.open + "," + line.high + "," + line.low + "," + line.close + "\n";
	}
	return csv;
}

FYI: I also tried to remove all semicolons, but it gives me the same error.

There is no "of" operator in Microsoft JScript:

You have this:

for(line of arr) {

there is no such thing as of operator in Microsoft JScript

Correct code should be:

for(line in arr) {

You need to understand that Javascript has many flavors and version and MS JScript (a part of Microsoft Active Scripting Technologies, is NOT the same as you have in the browser). It is used by Windows Scripting Host and is pretty old and does not have many new additions that for example Node.js has.

MS JScript used by AmiQuote is version 5.8 and is compatible with following spec: ECMA-262 3rd edition + ECMA-327 (ES-CP)[note 3] + JSON (RFC 4627)

2 Likes

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.