Hello,
I'm having a strange issue parsing JSON in JavaScript within a Qualtrics question. The following code works fine:
var obj = '{"name":"John","age":30,"city":"New York"}';
document.getElementById("json").innerHTML = JSON.parse(obj).age;
That is, it shows "30" for the question, corresponding to the age in the JSON.
But weirdly, this doesn't work:
var obj = '${e://Field/message}';
document.getElementById("json").innerHTML = JSON.parse(obj).age;
Here, the embedded data stored in the "message" variable is the exact same string stored in "obj" in the first code block. JSON.parse, however, fails to run. I'm a bit puzzled given that the strings seem to be literally identical; however, I figure that the embedded data must be being parsed in some strange way. I thought somebody here might know what's going on.
Many thanks.
Best answer by rondev
View original