fromJson static method
Returns a new CreateQuestionConfigBody instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static CreateQuestionConfigBody? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
assert(json.containsKey(r'name'), 'Required key "CreateQuestionConfigBody[name]" is missing from JSON.');
assert(json[r'name'] != null, 'Required key "CreateQuestionConfigBody[name]" has a null value in JSON.');
assert(json.containsKey(r'question'), 'Required key "CreateQuestionConfigBody[question]" is missing from JSON.');
assert(json[r'question'] != null, 'Required key "CreateQuestionConfigBody[question]" has a null value in JSON.');
assert(json.containsKey(r'type'), 'Required key "CreateQuestionConfigBody[type]" is missing from JSON.');
assert(json[r'type'] != null, 'Required key "CreateQuestionConfigBody[type]" has a null value in JSON.');
assert(json.containsKey(r'reportingOrder'), 'Required key "CreateQuestionConfigBody[reportingOrder]" is missing from JSON.');
assert(json[r'reportingOrder'] != null, 'Required key "CreateQuestionConfigBody[reportingOrder]" has a null value in JSON.');
return true;
}());
return CreateQuestionConfigBody(
name: mapValueOfType<String>(json, r'name')!,
question: mapValueOfType<String>(json, r'question')!,
helpText: mapValueOfType<String>(json, r'helpText'),
type: mapValueOfType<String>(json, r'type')!,
numStars: mapValueOfType<double>(json, r'numStars'),
min: mapValueOfType<double>(json, r'min'),
max: mapValueOfType<double>(json, r'max'),
defaultValue: mapValueOfType<double>(json, r'defaultValue'),
labelNegative: mapValueOfType<String>(json, r'labelNegative'),
labelPositive: mapValueOfType<String>(json, r'labelPositive'),
customOptions: QuestionConfigCustomOptionsInner.listFromJson(json[r'customOptions']),
subQuestionIds: json[r'subQuestionIds'] is Iterable
? (json[r'subQuestionIds'] as Iterable).cast<String>().toList(growable: false)
: const [],
alwaysShowSubQuestions: mapValueOfType<bool>(json, r'alwaysShowSubQuestions'),
reportingOrder: mapValueOfType<double>(json, r'reportingOrder')!,
);
}
return null;
}