Read audio stimuli from json file #2605
Answered
by
jodeleeuw
ZifengLIU143
asked this question in
Q&A
-
Hi all,
I firstly imported the json file.
Here is the coding for experiment:
But it does not work... Can anyone help me solve this? |
Beta Was this translation helpful? Give feedback.
Answered by
jodeleeuw
Apr 29, 2022
Replies: 1 comment 1 reply
-
Hi @ZifengLIU143, It's not possible to directly import a JSON file like this. Instead, you can convert the JSON file to a JS variable like this: var demostimuli = [
{
"Item": "S1",
"nameFile": "4036jiu14.mp3",
"Sequence": 369,
"Frame": 4,
"Error": "T",
"Position": 4,
"correctResp": 9,
"pathFile": "soundemo/4036jiu14.mp3"
},
{
"Item": "S2",
"nameFile": "5liao40935.mp3",
"Sequence": 6093,
"Frame": 5,
"Error": "C",
"Position": 1,
"correctResp": 6,
"pathFile": "soundemo/5liao40935.mp3"
}
] Then load in the JS file: <script src="demostimuli.js" type="text/javascript"></script> Then I think it should work. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ZifengLIU143
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @ZifengLIU143,
It's not possible to directly import a JSON file like this. Instead, you can convert the JSON file to a JS variable like this:
Then load in the JS file:
Then I think it should work.