Decodes SurveyJS-compatible JSON data or maps into DynamicForm.Instance structs.
This module handles the conversion of SurveyJS-format JSON form configurations into proper Elixir structs, including nested elements and special types.
SurveyJS Format
This decoder accepts SurveyJS-compatible JSON format. See: https://surveyjs.io/form-library/documentation
Examples
iex> json = ~s({"id": "my-form", "title": "My Form", "elements": []})
iex> map = Jason.decode!(json)
iex> DynamicForm.Instance.Decoder.decode_instance(map)
%DynamicForm.Instance{id: "my-form", title: "My Form", elements: []}
Summary
Functions
Decodes question choices.
Decodes a DateTime from an ISO8601 string.
Decodes a single element based on its type.
Decodes a list of elements (questions and panels).
Decodes a map into a DynamicForm.Instance struct.
Decodes a panel or HTML element map into an Instance.Element struct.
Decodes a question map into an Instance.Question struct.
Decodes a single validator map into an Instance.Validator struct.
Decodes a validator list.
Functions
Decodes question choices.
SurveyJS supports:
- Simple strings: ["option1", "option2"]
- Objects: [{"value": "v1", "text": "Label 1"}, ...]
Decodes a DateTime from an ISO8601 string.
Decodes a single element based on its type.
SurveyJS uses type to distinguish between question types and element types.
Decodes a list of elements (questions and panels).
Decodes a map into a DynamicForm.Instance struct.
Supports SurveyJS format with pages array or flat elements array.
Decodes a panel or HTML element map into an Instance.Element struct.
Decodes a question map into an Instance.Question struct.
Decodes a single validator map into an Instance.Validator struct.
Decodes a validator list.