Question T465
Visible to All Users

Modified JSON of Question Result

created 7 years ago

How do i modified the JSON of result?

Before
Clipboard-File-1.png

After
Clipboard-File-2.png

Comments (2)

    I can obtain the result but the result json string is {"xxx" : "yyy"}

    I want to change the json string to [{"questiono" : "xxx" , "answerno": "yyy"}}

    I did look the ways of changing it but dunno how the survey library works for the result data.

      You can precess survey result JSON in the onComplete handler:

      JavaScript
      survey .onComplete .add(function (result) { var modifiedData = Object.keys(result.data).map(function(qName) { return { questionNo: qName, answerNo: result.data[qName] } }); document .querySelector('#surveyResult') .innerHTML = "result: " + JSON.stringify(modifiedData); });

      Here is the example - https://plnkr.co/edit/VMEs1QlqJeros8nXGWNn?p=preview