Survey-library: generate json survey is not valid

Created on 29 Apr 2016  路  8Comments  路  Source: surveyjs/survey-library

why the input json to create a survey isn't valid json?

Most helpful comment

Options "Generate Valid JSON" and "Generate Readable JSON" are added.
Updated http://surveyjs.org/builder/ and http://dxsurvey.com
To set them manually use:
var options = {}; options.generateValidJSON = true; var editor = new SurveyEditor.SurveyEditor("editor", options);
to show options menu in the editor set:
editor.showOptions = true;

I believe the issue is solved.

Thank you,
Andrew

All 8 comments

I am using JSON5 to generate the JSON in the Visual Editor - http://json5.org/.
This extension is easier to maintain by humans, IMHO.

You may use the standard/valid JSON - it should work as well.
Do you have any issues with this JSON5?
If yes, please describe. I may add the standard JSON generation optionally.

Thank you,
Andrew

I didn't see this issue. There is a PR in the editor repository dealing with this issue https://github.com/andrewtelnov/surveyjs.editor/pull/7

The issue with the current output is simply that it is not valid JSON. In JSON it is mandatory to double-quote the keys. See also: http://json.org/

JSON5 is not a subset of JSON, it is a deviation, and thus not compatible with JSON.

I will add a valid JSON generation as an option.

Added options dropdown button:
http://surveyjs.org/builder/
I will add this functionality to dxsurvey.com later.

Options "Generate Valid JSON" and "Generate Readable JSON" are added.
Updated http://surveyjs.org/builder/ and http://dxsurvey.com
To set them manually use:
var options = {}; options.generateValidJSON = true; var editor = new SurveyEditor.SurveyEditor("editor", options);
to show options menu in the editor set:
editor.showOptions = true;

I believe the issue is solved.

Thank you,
Andrew

Thank you, that saves us a LOT of time :-)

@andrewtelnov this should really go in the docs or a FAQ or something. Got lucky searching through the issues but I would have been really frustrated and worried as I was initially going to eval() the text output into an object which is very insecure.

@c0bra You are right. We need documentation.
Unfortunately, we are not able to produce a quality docs right now. We will work on them later.
What we can do and actually had to some times ago, create an example and describe all available options. I have added this task to our TODO list.

Thank you,
Andrew

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nadialo picture nadialo  路  4Comments

testweird123 picture testweird123  路  4Comments

alexmc6 picture alexmc6  路  3Comments

Lordchapter picture Lordchapter  路  3Comments

aslanbeily picture aslanbeily  路  4Comments