Closed agelospanagiotakis closed 1 year ago
@agelospanagiotakis Unfortunately, there is no any document with what you are asking. Probably it is time to think about documentation. However, you may go to: http://surveyjs.org/builder/ Drop a question, set it's properties and click on "JSON Editor" tab. You will be able to understand the schema. After that, you may click on Test Survey and run it. On complete page the result/data JSON will be shown.
Thank you, Andrew
I was just wondering if the position on this has changed? It would be very useful to have a json schema to validate the surveyjs structure programmatically.
After playing around for some time, i think the json is poorly design, their schema keep changing for different scenario ( e.g. language , rating with numbers or self defined value, if question key and option using default value ) , as there is no documentation and to me is free style for the schema
what i can do is to try all the possibilities and see what kind of variety they change for same question type
@duncancrawford @qkchung We can generate the json scema, since all our properties/classes in our JSON metadata anyway and we may get missing types and properties/object titles from typedoc, as we do for our API documentation. I have strongly believe that I will be able to make some modification to this repo to make it happens.
I can understand how to structure the inheritance in this doc. However, I can't figure out, how to struction "elements -> element type".
elements: [
{
type: "elementType",
name: "",
...
}
]
where elementType can be "panel" (another container), or any question type, that should be describe seperately. What should we write?
Additionally, we support the following schema, to make it easy to create a simple one page survey:
{
elements: [{type: "text", question: "question1"}]
}
That actually should be:
{
pages: [
{
elements: [{type: "text", question: "question1"}]
}
}
}
Should we describe only the variant with pages? SurveyJS Builder (Editor) will generate the second variant of course.
What do you think?
@andrewtelnov not sure I understand the question but would this https://jsonschema.net/ help the thought pattern?
@duncancrawford Nevermind, I beleive I understand how it should be done.
Anyway, I am adding this functionality into our TODO list and I hope to comeback here with the first variant in two-three weeks. We want to generate it automatically, on every commit or on every version tag commit.
Thank you, Andrew
@andrewtelnov any update on this?
@duncancrawford Unfortunately nothing has been done. We are busy with improving Survey Creator usability and working on export to PDF. I may look at it on this week. If I would not be able to implement it in one-two days, I will wait untill we finish with export to PDF.
Thank you, Andrew
Lack of the documentation of the response seems like a joke to me. It drops out all the excellency of the project.
Please, seriously, make it a top priority to document out all the response format then.
Thanks.
@revskill10 Are you talking about Survey JSON schema or about our public and private API or our Survey Service?
Thank you, Andrew
@andrewtelnov It's about response format when user complete a survey.
@revskill10 Do you need to do anything with it? It is simiple, for simple questions: {questionName: questionValue, ...} You may use survey.getPlainData() to get results in the flat format for complex questions like: matrices or panel dynamic.
Thank you, Andrew
@andrewtelnov No, user doesn't have to debug to find out format. Please write down it in the documentation somewhere else.
@revskill10 Yes, indeed. We will improve the situation here.
Thank you, Andrew
Guys, please review the first variant and give your feedback.
Thank you, Andrew surveyjs_definition.zip
I don't really see the value of using JSON Schema for documentation purposes. Why not flesh out the packaged TypeScript declaration files instead? There are a lot any
that could be replaced with precise type definitions.
TypeScript type definitions are powerful and expressive, and come with the added benefit of being understood by IDEs and usable by tools like TypeDoc to generate static webpage documentation
@Wenzil We are using TypeDoc to generate our library API documentation and we are using the same code to generate JSON Schema.
Thank you, Andrew
the urgent thing is making the JSON schema static. Currently, json schema chaged when you edit the title of a control. For example, if i change the title of a checkbox, it's schema will change from string to object. So, in a strong typed server side, like C#, Java ... we have to care about both case. And worst, we can't create a class for deserializing JSON. Instead, i have to work with dynamic object, which is terrible experience.
@lekhasy , agree Since my project is working on multilanguage project , we encounter at least 3 variant of data types when handling simple text with multilanguage
@lekhasy @qkchung Guys, many our SurveyJS users do not use Survey Creator to build survey JSON and write it in text editor. The most of our users do not need multiple language support, they do surveys for one language only. It would be hard to explain them, why should they write:
title: {default: "My title"}
or title: {en: "My title
}, instead of title: "My title"
.
They would find the first two variants over complicated and they will absolutely right.
Moreover, we do not have multiple lanuage support in our first versions, about two years ago. So only title: "My title"
was possible. However, our current SurveyJS serializer (v1.1.0) is able to work with any survey JSON created in very first alfa versions and we do all possible to make sure it will not change in the future.
The same story with choices. choices: ["item1", 1, {value: 1, text: "My text for value 1"}]
.
I understand it requries to write several additional lines of code on your back-end that you may do not need, but here is the reality. We can't change it.
Thank you, Andrew
Guys, please review the first variant and give your feedback.
Thank you, Andrew surveyjs_definition.zip
First of all thanks for the library.
Do you have an updated definition or a way to generate it from the source?
I guess if we couldn't change the default, we still able to write a util method to standardize the JSON schema before send it to server side. Developers can choose to use it or not. Working with json is much more simple with Javascript.
@cur3n4 I have created a new version. surveyjs_definition.zip
Thank you, Andrew
@andrewtelnov I am just wondering why not add a version number to the questionnaire schema so everything can be strong typed according to different versions.
And thanks a lot for the schema. This is really helpful. We are currently trying to do some interesting things base on surveyjs.
dynamic forms. like react-jsonschema-form
flutter portal to parse and display questionnaire on Android and IOS. Although Webview is a powerful solution to do surveys on mobile platform, but it fits only part of our requirements
adapt third-party questionnaires to surveyjs
So I think if the schema is open and easy to parse, there would be more cases we can use beyond website
There are something bugs in the schema file. I already updated in my gist surveyjs_definition.json
@Goxiaoy Not totally sure, but under the panelbase definition, under properties should there be a name prop? The json returned when I save with the SurveyCreator shows me a name prop on the same level as elements.
I am assuming the json passed to new Survey.Model(json)
is the same schema as the surveyCreator.Json (from the React quickstart example)
I think the same goes for the elementbase
@isabellachen You are right. I move name from Question
to Elementbase
And for those who use C#, I generated class from NJsonSchema Survey.cs
The validator base definition in the enriched json schema is broken. The Creator JSON result for the various validator types do not end by -validator.
If anyone else is trying to use that schema to generate de/serialization logic for other languages beware and use the C# implementation as reference.
To all: You will be able to use the following code from v1.8.14, that we are going to release on this week:
JSON.stringify(Survey.Serializer.generateSchema(), null, 4);
It will generate the JSON Schema of your current Survey version. If there is something wrong here, please write to us.
Here is the related issue.
Thank you, Andrew
I think this one can be closed!
can you please provide the schemas of the a)survey and b)responses ? i want to create c# classes on the server side