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.
JSON string saved as embedded data
Best answer by rondev
Can you try doing console.log of the message embedded data and check what is displayed?
Sign up
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login to the Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
