70 lines
1.9 KiB
Dart
70 lines
1.9 KiB
Dart
// To parse this JSON data, do
|
|
//
|
|
// final quizQuestionResult = quizQuestionResultFromJson(jsonString);
|
|
|
|
import 'dart:convert';
|
|
|
|
QuizQuestionResult quizQuestionResultFromJson(String str) =>
|
|
QuizQuestionResult.fromJson(json.decode(str));
|
|
|
|
String quizQuestionResultToJson(QuizQuestionResult data) =>
|
|
json.encode(data.toJson());
|
|
|
|
class QuizQuestionResult {
|
|
final int status;
|
|
final bool error;
|
|
final List<Datum> data;
|
|
|
|
QuizQuestionResult({
|
|
required this.status,
|
|
required this.error,
|
|
required this.data,
|
|
});
|
|
|
|
factory QuizQuestionResult.fromJson(Map<String, dynamic> json) =>
|
|
QuizQuestionResult(
|
|
status: json["status"],
|
|
error: json["error"],
|
|
data: List<Datum>.from(json["data"].map((x) => Datum.fromJson(x))),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"status": status,
|
|
"error": error,
|
|
"data": List<dynamic>.from(data.map((x) => x.toJson())),
|
|
};
|
|
}
|
|
|
|
class Datum {
|
|
final int questionId;
|
|
final List<String> answers;
|
|
final String question;
|
|
final bool isCorrect;
|
|
final List<String> correctAnswers;
|
|
|
|
Datum({
|
|
required this.questionId,
|
|
required this.answers,
|
|
required this.question,
|
|
required this.isCorrect,
|
|
required this.correctAnswers,
|
|
});
|
|
|
|
factory Datum.fromJson(Map<String, dynamic> json) => Datum(
|
|
questionId: json["question_id"],
|
|
answers: List<String>.from(json["answers"].map((x) => x)),
|
|
question: json["question"],
|
|
isCorrect: json["is_correct"],
|
|
correctAnswers:
|
|
List<String>.from(json["correct_answers"].map((x) => x)),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"question_id": questionId,
|
|
"answers": List<dynamic>.from(answers.map((x) => x)),
|
|
"question": question,
|
|
"is_correct": isCorrect,
|
|
"correct_answers": List<dynamic>.from(correctAnswers.map((x) => x)),
|
|
};
|
|
}
|