- Posts: 11
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Exported JSON results not in correct JSON format??
- garf
- Topic Author
- Offline
- New Member
Less
More
7 years 11 months ago #136105
by garf
Exported JSON results not in correct JSON format?? was created by garf
Given a simple survey, here is the results exported as codes.
{
"responses": [
{
"14": {
"id": "14",
"submitdate": "2016-05-11 03:30:08",
"lastpage": "11",
"startlanguage": "en",
"startdate": "2016-05-11 03:29:29",
"datestamp": "2016-05-11 03:30:08",
"Assesed": "F1",
"L1[SQ1]": "0",
"L1[SQ2]": "1",
"L1[SQ3]": "2",
"L1[SQ4]": "3",
"L1[SQ5]": "4",
"L2[SQ001]": "B1",
"L2[SQ2]": "B2",
"L2[SQ3]": "B3",
"L2[SQ4]": "B4",
"L2[SQ5]": "B4",
"L3[SQ001]": "A6",
"L3[SQ2]": "A6",
"L3[SQ3]": "A6",
"L3[SQ5]": "A6",
"G4": "",
"G5": "",
"G6": "",
"G7": ""
}
}
]
}
however, array type questions have square brackets to denote their sub questions ie: "L1[SQ5]" .
I don't think that's allowed in proper JSON format as it breaks XPATH and JSON queries on the JSON string being output. For instace.. you can use a wildcard //L1* to return all the scores for questions beginning L1, but you can never query //L1[SQ5] .
Any idea how I can work around this in XPATH or where to fix the code that outputs the string? perhaps L1_SQ5 would be a preferred format?
Thanks!
Garf
{
"responses": [
{
"14": {
"id": "14",
"submitdate": "2016-05-11 03:30:08",
"lastpage": "11",
"startlanguage": "en",
"startdate": "2016-05-11 03:29:29",
"datestamp": "2016-05-11 03:30:08",
"Assesed": "F1",
"L1[SQ1]": "0",
"L1[SQ2]": "1",
"L1[SQ3]": "2",
"L1[SQ4]": "3",
"L1[SQ5]": "4",
"L2[SQ001]": "B1",
"L2[SQ2]": "B2",
"L2[SQ3]": "B3",
"L2[SQ4]": "B4",
"L2[SQ5]": "B4",
"L3[SQ001]": "A6",
"L3[SQ2]": "A6",
"L3[SQ3]": "A6",
"L3[SQ5]": "A6",
"G4": "",
"G5": "",
"G6": "",
"G7": ""
}
}
]
}
however, array type questions have square brackets to denote their sub questions ie: "L1[SQ5]" .
I don't think that's allowed in proper JSON format as it breaks XPATH and JSON queries on the JSON string being output. For instace.. you can use a wildcard //L1* to return all the scores for questions beginning L1, but you can never query //L1[SQ5] .
Any idea how I can work around this in XPATH or where to fix the code that outputs the string? perhaps L1_SQ5 would be a preferred format?
Thanks!
Garf
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13643
- Thank you received: 2491
7 years 11 months ago #136110
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Exported JSON results not in correct JSON format??
Hi,
Sure : using EM code by default seems really the best solution.
We have an option available in GUI export : this can not be set via API : api.limesurvey.org/classes/remotecontrol...hod_export_responses .
Best is to make
- A feature request to allow extrasettings in method_export_responses (all existing settings in GUI)
The JSON seems valid ( it's quoted) then not a bug.
Sure : using EM code by default seems really the best solution.
We have an option available in GUI export : this can not be set via API : api.limesurvey.org/classes/remotecontrol...hod_export_responses .
Best is to make
- A feature request to allow extrasettings in method_export_responses (all existing settings in GUI)
The JSON seems valid ( it's quoted) then not a bug.
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- garf
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
7 years 11 months ago #136170
by garf
Replied by garf on topic Exported JSON results not in correct JSON format??
Thanks for that!
Tested from the GUI and I see what you mean. OK, put it over at the bug tracker as 11172 I hope I did it correctly, I didn't see a feature request option.
If there was a way to xpath or JSON query on square brackets, I would say all is good. But seeing those brackets have unique operations in the query, []'s are probably not the best choice of delimiters. The EM takes care of that though so hopefully it can get in for an upcoming update.
Thanks again!
Tested from the GUI and I see what you mean. OK, put it over at the bug tracker as 11172 I hope I did it correctly, I didn't see a feature request option.
If there was a way to xpath or JSON query on square brackets, I would say all is good. But seeing those brackets have unique operations in the query, []'s are probably not the best choice of delimiters. The EM takes care of that though so hopefully it can get in for an upcoming update.
Thanks again!
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11658
- Thank you received: 2742
7 years 11 months ago #136186
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Exported JSON results not in correct JSON format??
Top right corner in the bug tracker allows to switch to "feature request" (drop down)
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- garf
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
7 years 11 months ago #136189
by garf
Replied by garf on topic Exported JSON results not in correct JSON format??
Perfect, thanks!
The topic has been locked.