π₯Information retreival
This section will teach you how to retreive saved information in SynoSurvey.
How to check saved answers
One main difference between SynoTool and SynoSurvey is the way we can recover the responded answers. Every answer in Survey is saved in an JSON, commonly know as a Javascript Object Notation.
If you are testing, you can inspect the page by clicking F12
or by doing right click > inspect
.

This will open the developers tool for web programmers. Then, you need to go to the Elements tab. Right there you will find a script tag where they JSON is allocated. You can simply expand it to see what data has been saved from previous questions. This should look like this.

The variable holds the responses is called response. Each answer is wrapped into curly braces. This can contain different information regarding the type of the question. For more details, see the table below.
Structure of the saved information
Here is a table that describes the meaning of each variable in the JSON.
Simple response variables
pageCode
Name of the page where the question is in.
Example:
questionCode
Name of the question code.
Example:
code
Answer code that belongs to the question code.
Example:
label
The text of each answer in the question.
Example:
value
The introduced value written in open texts.
They are also received when Other option is enabled in single/multiple questions.
Single and multiple questions:
Open texts fields:
Matrices response variables
pageCode
Name of the page where the question is in.
Example:
questionCode
Name of the question code.
Example:
rowCode
The code of each row. Example:
rowLabel
The text inside each row.
Example:
columnCode
The code of each column. Example:
columnLabel
The label of each column.
Example:
value
Variable is not used in this type of questions
Read answers using Javascript
If you want to retreive the whole information in the json file you can use the following snippet.
Panelist & Parameters metadata
let guid = response.parameters.id; // GUID
let source = response.parameters.source; // Provider source, i.e. 1 (Syno), 2 (Cint Buyer API), 3 (Cint Access)
let gender = response.parameters.g; // Gender where M: Male and F: Female
let year_of_birth = response.parameters.yob; // Year of birth in yyyy format
let panelist_id = response.parameters.pid; // Panelist ID
let postcode = response.parameters.p; // Postal code
πSingle & βοΈ Multiple Choice
// Read all selected answer codes from a single/multiple choice
let selected_codes = response.answers.filter(answer => answer.questionCode == "Q1").map(answer => answer.code);
// Read all selected labels from a single/multiple choice
let selected_labels = response.answers.filter(answer => answer.questionCode == "Q1").map(answer => answer.label);
// Read all values from a single/multiple choice (for free answers in single/multiple choice)
let values = response.answers.filter(answer => answer.questionCode == "Q1").map(answer => answer.value);
βΊοΈ Single & βΉοΈMultiple Choice Matrices
// Read all selected answer codes from a single/multiple choice matrix
let selected_row_codes = response.answers.filter(answer => answer.questionCode == "Q1").map(answer => answer.rowCode);
// Read all selected labels from a single/multiple choice matrix
let selected_row_labels = response.answers.filter(answer => answer.questionCode == "Q1").map(answer => answer.rowLabel);
// Read all selected answer codes from a single/multiple choice matrix
let selected_column_codes = response.answers.filter(answer => answer.questionCode == "Q1").map(answer => answer.columnCode);
// Read all selected labels from a single single/multiple choice matrix
let selected_column_labels = response.answers.filter(answer => answer.questionCode == "Q1").map(answer => answer.columnLabel);
βοΈ Single & Multiple Open Text
Last updated
Was this helpful?