Notes on Converting JSON to a JavaScript Object

Let us assume that you have a converter stack in a step action and somewhere in that stack there is a Convert Using JavaScript converter. This converter gets access to the output from the previous converter as a variable named INPUT that one can use in the JavaScript that is used by the converter. The value of the INPUT variable is always a String. In the table below you can see how the various values that the INPUT variable can have are converted:

INPUT Value

JavaScript (OUTPUT =)

Result (OUTPUT value)

5

OUTPUT = INPUT

5

5

OUTPUT = INPUT + 3

53

5

OUTPUT = eval(INPUT)

5

5

OUTPUT = eval(INPUT) + 3

8

5

OUTPUT = eval(INPUT + 3)

53

5

OUTPUT = eval(INPUT + " + 3")

8

[1,2,3]

OUTPUT = INPUT[0]

[

[1,2,3]

OUTPUT = eval(INPUT)[0]

1

{ “a”: 5 }

OUTPUT = eval(INPUT).a

“Syntax Error”

{ “a”: 5 }

OUTPUT = eval("var x=" + INPUT + "; x;").a;

5

Note the following when converting JSON to JavaScript: