from json to object dart - json

Good afternoon, I may have found a small error, but I can't figure it out until now..
I have the following class in dart, the purpose of this class is to receive json and transform each field to object
class Attributes {
final String lpn; //itemId
final String type; //itemType (REEL,FEEDER,ETC)
final String feederContainer; //containerId
final String feederSide; //locationInContainer(A o B)
final String locationInTool; //locationInTool
Attributes(
{required this.lpn,
required this.type,
required this.feederContainer,
required this.feederSide,
required this.locationInTool});
factory Attributes.fromJson(Map json) {
return Attributes(
lpn: json['itemId'],
type: json['itemType'],
feederContainer: json['containerId'],
feederSide: json['locationInContainer'],
locationInTool: json['locationInTool'],
);
}
}
class PartNumberAt {
final String partNumber; //partNumber
final String quantity; //quantity
final String initialQuantity; //initialQuantity
PartNumberAt(
{required this.partNumber,
required this.quantity,
required this.initialQuantity});
factory PartNumberAt.fromJson(Map json) {
return PartNumberAt(
partNumber: json['partNumber'],
quantity: json['quantity'],
initialQuantity: json['initialQuantity'],
);
}
}
//partnumber RawMaterial
class ReelPartNumber {
final PartNumberAt partNumberAt;
ReelPartNumber({required this.partNumberAt});
factory ReelPartNumber.fromJson(Map json) {
return ReelPartNumber(
partNumberAt: PartNumberAt.fromJson(json['attributes']),
);
}
}
class ReelLpn {
Attributes? attributes;
ReelPartNumber? reelPartNumber;
ReelLpn(
{required Attributes attributes, required ReelPartNumber reelPartNumber});
factory ReelLpn.fromJson(Map json) {
return ReelLpn(
attributes: Attributes.fromJson(json['attributes']),
reelPartNumber: ReelPartNumber.fromJson(json['RawMaterial']),
);
}
}
and I have a file where I make http requests, the request returns the following
{
"attributes": {
"itemId": "0605007783",
"itemKey": "14992663",
"itemType": "REEL",
"itemTypeClass": "Component Lot",
"containerId": "FA0210AEF424292",
"locationInContainer": "B",
"toolContainerId": "SMT6",
"locationInTool": "10004-B",
"quarantineLocked": "false",
"expired": "false",
"initTmst": "2022-01-20T09:40:30.969-03:00"
},
"RawMaterial": {
"attributes": {
"partNumber": "11201312001166",
"partNumberDesc": "",
"supplierId": "DEFAULT",
"quantity": "2497.0",
"initialQuantity": "5000.0",
"rejectedQuantity": "3.0",
"manualAdjustmentQuantity": "548.0"
},
}
and the request is made as follows
Future<ReelLpn?> getReelData(String lpn) async {
http.Response response = await http.get(Uri.parse(apiUrl+'/$lpn'));
if (response.statusCode == 200) {
Map data = (json.decode(response.body)); //conver to json
print(data);
ReelLpn reelLpn = ReelLpn.fromJson(data); //transform json to ReelLpn
return reelLpn;
}
return null;
}
and I call the service as follows
ReelLpn? data = await CogiscanService().getReelData('0605007783');
print(data?.attributes?.type);
my problem starts there, when I print
print(data?.attributes?.type);
it returns null, I put several prints, in the ReelL class, Attributes and PartNumber, to see if I was reading the Map correctly, and they definitely read correctly.
So why when I want to access any of the fields does it return null?

Change your ReelLpn Constructor. you are not referencing the class members... thats why its always null.
ReelLpn({required this.attributes, required this.reelPartNumber});

Related

Error To show Data Parsed Json In Flutter

I Have One Http Post Method Like This :
class ApiClientController extends GetxController {
Future<GetSideMenuInfoError?> GetInfoAfterLogin() async {
String? value = await storage.read(key: 'skey');
try {
final response = await dio.post(
Constant.baseUrl,
options: Options(
headers: {
"omax-apikey": "apikey",
},
),
data: {
"function": "portal_get_information",
"params": {
"portal_version": "1.0.0",
"portal_os": "linux",
"portal_os_version": "10",
"portal_browser": "chrome",
"portal_guid": "fd298776-6014-11ed-adbc-5256454165"
}
},
);
//print(response.data.toString());
GetSideMenuInfoError? responseBody = getSideMenuInfoErrorFromJson(response.data.toString());
return responseBody;
} on DioError catch (e) {
//return ;
print(e);
}
return null;
//IMPLEMENT USER LOGIN
}
}
And The Result Post Method My Json :
{
"result": 55456465,
"data": {
"reason": "session expired or not valid",
"uuid": "01dfca14-625559-11ed-aafa-0056546546"
}
}
Used This https://app.quicktype.io/ for Parsed Json To dart File Result Like This:
import 'package:meta/meta.dart';
import 'dart:convert';
GetSideMenuInfoError? getSideMenuInfoErrorFromJson(String str) => GetSideMenuInfoError?.fromJson(json.decode(str));
class GetSideMenuInfoError {
GetSideMenuInfoError({
#required this.result,
#required this.data,
});
final int? result;
final Data? data;
factory GetSideMenuInfoError.fromJson(Map<String, dynamic> json) => GetSideMenuInfoError(
result: json["result"],
data: Data.fromJson(json["data"]),
);
}
class Data {
Data({
#required this.reason,
#required this.uuid,
});
final String? reason;
final String? uuid;
factory Data.fromJson(Map<String, dynamic> json) => Data(
reason: json["reason"],
uuid: json["uuid"],
);
}
And My Question Is : How Can I Show value in Dart File Like reason or uuid In Other Class ?
My Way like This in Other Class And Not Worked:
In The Build Widget :
final apiClientController = Get.find<ApiClientController>();
apiClientController.GetInfoAfterLogin();
GetSideMenuInfoError? getSideMenuInfoError;
title: getSideMenuInfoError != null ?
Text(getSideMenuInfoError.result.toString()):Text('',),
Thank You For Helping Me...

How To access data in a list but inside the list has nested maps

Hello Im trying to get data from the Jasonplaceholder Api, and I want to map it in a dart model
but I tried videos on YouTube and none of them work and I use autogenerated models but the data that received are inside a list but in that list have nested maps
var myMap=[{
"name" : "Ravindu",
"age" : 20,
"scl" : "smc",
"address" :
{
"city" : "Kegalle",
"country" : "sri lanka"
}
},
{
"name" : "Ravindu1",
"age" : 20,
"scl" : "smc1",
"address" :
{
"city" : "Kegalle1",
"country" : "sri lanka1"
}
}];
like this I want this to map to a Molde class and also, I want to know how to access Items inside this map tried myMap[0]["address"] but it only retrieve the whole map of address in the 0 index
so How can I pass these type of Json data to a model class
this is the actual url im working with
'''final String url ="https://jsonplaceholder.typicode.com/users"'''
I get this error when I try this on darpad
Uncaught Error: TypeError: Instance of 'JsLinkedHashMap<String, String>': type 'JsLinkedHashMap<String, String>' is not a subtype of type 'List'
this is the code I tried on dartpad
void main() {
var myMap=[{
"name" : "Ravindu",
"age" : 20,
"scl" : "smc",
"address" :
{
"city" : "Kegalle",
"country" : "sri lanka"
}
},
{
"name" : "Ravindu1",
"age" : 20,
"scl" : "smc1",
"address" :
{
"city" : "Kegalle1",
"country" : "sri lanka1"
}
}];
print(myMap[0]);
var addressList = myMap[0]["address"]["city"];
print(addressList);
(addressList as List).forEach((i){
print(i["country"]);
});
}
The addressList will get from myMap[0]["address"] which will be another map. On Map, forEach callback provide key and value .forEach((key, value) {
void main() {
List<Map<String, dynamic>> myMap = [
{
"name": "Ravindu",
"age": 20,
"scl": "smc",
"address": {"city": "Kegalle", "country": "sri lanka"}
},
{
"name": "Ravindu1",
"age": 20,
"scl": "smc1",
"address": {"city": "Kegalle1", "country": "sri lanka1"}
}
];
print(myMap[0].toString());
final addressList = myMap[0]["address"]["city"];
print(addressList.toString()); // kegalle
final Map<String, String> address = myMap[0]["address"];
address.forEach((key, value) {
print(" $key $value");
});
}
I am also using Dart class generator extion
class Person {
final String? name;
final int? age;
final String? scl;
final Address? address;
Person({
this.name,
this.age,
this.scl,
this.address,
});
Map<String, dynamic> toMap() {
final result = <String, dynamic>{};
if(name != null){
result.addAll({'name': name});
}
if(age != null){
result.addAll({'age': age});
}
if(scl != null){
result.addAll({'scl': scl});
}
if(address != null){
result.addAll({'address': address!.toMap()});
}
return result;
}
factory Person.fromMap(Map<String, dynamic> map) {
return Person(
name: map['name'],
age: map['age']?.toInt(),
scl: map['scl'],
address: map['address'] != null ? Address.fromMap(map['address']) : null,
);
}
String toJson() => json.encode(toMap());
factory Person.fromJson(String source) => Person.fromMap(json.decode(source));
}
class Address {
final String? city;
final String? country;
Address({
this.city,
this.country,
});
Map<String, dynamic> toMap() {
final result = <String, dynamic>{};
if(city != null){
result.addAll({'city': city});
}
if(country != null){
result.addAll({'country': country});
}
return result;
}
factory Address.fromMap(Map<String, dynamic> map) {
return Address(
city: map['city'],
country: map['country'],
);
}
String toJson() => json.encode(toMap());
factory Address.fromJson(String source) => Address.fromMap(json.decode(source));
}
try to get the json structure with this model.
First of all be sure to have json_annotation and http as a normal dependency, and json_serializable, build_runner as a dev dependencies.
Example of pubspec.yaml:
dependencies:
json_annotation: ^4.7.0
# used for HTTP calls
http: ^0.13.5
# other dependencies
dev_dependencies:
build_runner: ^2.3.2
json_serializable: ^6.5.4
# other dependencies
Then you should create a model with the fromJson method. This is going to be used to deserialize the JSON you retrieve from the API call. I'm going to use a Dart file named user.dart
import 'package:json_annotation/json_annotation.dart';
part 'user.g.dart';
#JsonSerializable()
class User {
const User({
required this.id,
required this.name,
required this.username,
required this.email,
required this.address,
});
final int id;
final String name;
final String username;
final String email;
final Address address;
/// Connect the generated [_$UserFromJson] function to the `fromJson`
/// factory.
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
/// Connect the generated [_$UserToJson] function to the `toJson` method.
Map<String, dynamic> toJson() => _$UserToJson(this);
}
#JsonSerializable()
class Address {
const Address({
required this.city,
required this.street,
required this.zipcode,
});
final String city;
final String street;
final String zipcode;
factory Address.fromJson(Map<String, dynamic> json) =>
_$AddressFromJson(json);
Map<String, dynamic> toJson() => _$AddressToJson(this);
}
Now in your Terminal you should run flutter pub run build_runner build --delete-conflicting-outputs to build the generated file, in my case it will generate a file called user.g.dart.
Now you need a service to make the HTTP call and return the list of users, I'm going to create a file called users_service.dart
import 'dart:convert';
import 'package:stackoverflow/user.dart';
import 'package:http/http.dart' as http;
class UsersService {
Future<List<User>> getUsers() async {
final uri = Uri.parse('https://jsonplaceholder.typicode.com/users');
final response = await http.get(uri);
final responseString = response.body;
final jsonList = List.from(jsonDecode(responseString));
return jsonList.map((json) => User.fromJson(json)).toList();
}
}
Here you must focus on the jsonDecode method that converts the JSON to a Dart object, and in the User.fromJson method that deserializes the JSON object converting it into a valid User Dart class.
As you can see the address field is another class with its fromJson implementation.
This is the right way to perform JSON (de)serialization, because it doesn't involve doing it manually (more error prone)
Example usage:
import 'package:stackoverflow/users_service.dart';
Future<void> main() async {
final users = await UsersService().getUsers();
for (final user in users) {
print("${user.name} lives in ${user.address.city}");
}
}
which prints:
Leanne Graham lives in Gwenborough
Ervin Howell lives in Wisokyburgh
Clementine Bauch lives in McKenziehaven
Patricia Lebsack lives in South Elvis
Chelsey Dietrich lives in Roscoeview
Mrs. Dennis Schulist lives in South Christy
Kurtis Weissnat lives in Howemouth
Nicholas Runolfsdottir V lives in Aliyaview
Glenna Reichert lives in Bartholomebury
Clementina DuBuque lives in Lebsackbury

How to decode large json array in flutter

I have a rather large json file that I have downloaded using my flutter app from a web api that's around 200MB using
final response = Dio().get(uri, options: Options(responseType: ResponseType.plain));
(Using default Dio options also uses json decoding, resulting in an out of memory exception.
This is not directly part of my problem but maybe it helps)
Now the problem starts after obtaining the json string.
When I use jsonDecode on the response body I run out of memory. (maybe the same function Dio uses?)
final data = jsonDecode(response.body); this runs out of memory
The json object itself is an array with a lot of items with a format like this:
[
{"data": {independent data1}},
{"data": {independent data2}},
...
]
and i would be fine just decoding one item at a time instead of everything at once to reduce memory usage. Is there another way to do process all the items in this array? Something like
jsonArrayDecode(response.body, onItemDecode: (item) { /*do stuff with item */ });
Or do I have to write my own json reader that can sequentially decode it?
Thanks to #pskink, I managed to solve my problem. I used the ResponseType.stream from Dio to get stream which can be processed using the reviver function argument from the JsonDecoder. I process all the data in the reviver and ignore the data in the onData function of the listener.
...
final response = await dio.get(uri,
options: Options(responseType: ResponseType.stream);
Function reviver = (key, value) {
if (/*value is element from top level list*/) {
processItem(value);
return null;
}
return value;
}
final completer = Completer();
response.data.stream.cast<List<int>>()
.transform(utf8.decoder)
.transform(JsonDecoder(reviver))
.listen(null, onDone: () { completer.complete(); });
await completer.future;
...
If the problem is really that the data file is very large, then the problem can be solved by not storing unnecessary objects during parsing.
This will only make sense if not all of the data is needed, but only some of the data.
In this case, we are talking about filtering data on the fly, that is, directly during the data parsing process.
Below is a small example of how this can be implemented.
import 'package:fast_json/fast_json_selector.dart' as parser;
import 'package:fast_json/fast_json_selector.dart' show JsonSelectorEvent;
void main(List<String> args) {
// Select users from the list by indexes [2..3] and terminate selection
final users = <User>[];
final level = '{} data [] 0 {}'.split(' ').length;
final elementLevel = '{} data [] 0'.split(' ').length;
void select(JsonSelectorEvent event) {
final levels = event.levels;
if (levels.length == level) {
final index = event.levels[elementLevel - 1] as int;
if (index >= 2 && index <= 3) {
final map = event.lastValue as Map;
final user = User.fromJson(map);
users.add(user);
}
// Free up memory
event.lastValue = null;
if (users.length == 2) {
throw const _TerminateException();
}
}
}
try {
parser.parse(_data, select: select);
} on _TerminateException {
//
}
print(users.join(', '));
}
const _data = '''
{
"success":true,
"data":[
{
"id":1,
"name":"Leanne Graham",
"username":"Bret",
"email":"Sincere#april.biz",
"address":{
"street":"Kulas Light",
"suite":"Apt. 556",
"city":"Gwenborough",
"zipcode":"92998-3874",
"geo":{
"lat":"-37.3159",
"lng":"81.1496"
}
},
"phone":"1-770-736-8031 x56442",
"website":"hildegard.org",
"company":{
"name":"Romaguera-Crona",
"catchPhrase":"Multi-layered client-server neural-net",
"bs":"harness real-time e-markets"
}
},
{
"id":2,
"name":"Ervin Howell",
"username":"Antonette",
"email":"Shanna#melissa.tv",
"address":{
"street":"Victor Plains",
"suite":"Suite 879",
"city":"Wisokyburgh",
"zipcode":"90566-7771",
"geo":{
"lat":"-43.9509",
"lng":"-34.4618"
}
},
"phone":"010-692-6593 x09125",
"website":"anastasia.net",
"company":{
"name":"Deckow-Crist",
"catchPhrase":"Proactive didactic contingency",
"bs":"synergize scalable supply-chains"
}
},
{
"id":3,
"name":"Clementine Bauch",
"username":"Samantha",
"email":"Nathan#yesenia.net",
"address":{
"street":"Douglas Extension",
"suite":"Suite 847",
"city":"McKenziehaven",
"zipcode":"59590-4157",
"geo":{
"lat":"-68.6102",
"lng":"-47.0653"
}
},
"phone":"1-463-123-4447",
"website":"ramiro.info",
"company":{
"name":"Romaguera-Jacobson",
"catchPhrase":"Face to face bifurcated interface",
"bs":"e-enable strategic applications"
}
},
{
"id":4,
"name":"Patricia Lebsack",
"username":"Karianne",
"email":"Julianne.OConner#kory.org",
"address":{
"street":"Hoeger Mall",
"suite":"Apt. 692",
"city":"South Elvis",
"zipcode":"53919-4257",
"geo":{
"lat":"29.4572",
"lng":"-164.2990"
}
},
"phone":"493-170-9623 x156",
"website":"kale.biz",
"company":{
"name":"Robel-Corkery",
"catchPhrase":"Multi-tiered zero tolerance productivity",
"bs":"transition cutting-edge web services"
}
},
{
"id":5,
"name":"Chelsey Dietrich",
"username":"Kamren",
"email":"Lucio_Hettinger#annie.ca",
"address":{
"street":"Skiles Walks",
"suite":"Suite 351",
"city":"Roscoeview",
"zipcode":"33263",
"geo":{
"lat":"-31.8129",
"lng":"62.5342"
}
},
"phone":"(254)954-1289",
"website":"demarco.info",
"company":{
"name":"Keebler LLC",
"catchPhrase":"User-centric fault-tolerant solution",
"bs":"revolutionize end-to-end systems"
}
}
]
}''';
class Company {
final String name;
Company({required this.name});
#override
String toString() {
return name;
}
static Company fromJson(Map json) {
return Company(
name: json['name'] as String,
);
}
}
class User {
final String city;
final int id;
final String name;
User({required this.city, required this.id, required this.name});
#override
String toString() {
return '$id:$name from $city';
}
static User fromJson(Map json) {
return User(
city: json['address']['city'] as String,
id: json['id'] as int,
name: json['name'] as String,
);
}
}
class _TerminateException {
const _TerminateException();
}

flutter parsing JSON from firebase

I just started learning about flutter and try to use ScopedModel
and I get stuck at parsing JSON,
everything works until I try to get List of detail simulation but everything that I try just fails
this is my class for project and simulation
class Project {
String idProject;
List images;
List<Simulations> simulation;
Project({
#required this.idProject,
#required this.images,
#required this.simulation
});
}
class Simulations{
String period;
int profitProject;
int roi;
Simulations({
#required this.period,
#required this.profitProject,
#required this.roi
});
}
I made a separate class to get detail for simulation
this is a sample from JSON that I get from the firebase
{
"1554182068913": {
"idProject": "project id 1",
"images": [
1554181958565,
1554181955542,
1554181960876],
"simulation": [
{
"periode": "year 1",
"profitProject": 300000,
"roi": 5,
"uniqueKey": "YyCWbHjvm"
},
{
"periode": "year 1",
"profitProject": 100000,
"roi": 3,
"uniqueKey": "CvyU4SjrX"
},
{
"periode": "year 1",
"profitProject": 2000000,
"roi": 10,
"uniqueKey": "Tb_Qr5CIA"
}
],
}
}
I made function to get the data
Future<Null> fetchProjects() {
return http.get("JSON link")
.then<Null>((http.Response response) {
final List<Project> fetchedProjectList = [];
final Map<String, dynamic> projectListData = json.decode(response.body);
if (projectListData == null) {
_isLoading = false;
notifyListeners();
return;
}
projectListData.forEach((String projectId, dynamic projectData) {
final Project project = Project(
title: projectData['title'],
location: projectData['location'],
images: projectData['images'],
simulation: ???
);
fetchedProjectList.add(project);
}
What's missing here is JSON serialization. You need to convert the response to a Dart object, similar to what has been demonstrated on this guide. In Project class, you can add a fromJson() constructor to map the data.
factory Project.fromJson(Map<String, dynamic> json) {
return Project(
idProject: json['idProject'],
images: json['images'],
simulation: json['simulation'],
);
}

Parsing JSON that has a nested array of objects in Dart?

I am making a Flutter app and I am using The MovieDB api to get data. When I call the api and ask for a specific movie, this is the general format that I get back:
{
"adult": false,
"backdrop_path": "/wrqUiMXttHE4UBFMhLHlN601MZh.jpg",
"belongs_to_collection": null,
"budget": 120000000,
"genres": [
{
"id": 28,
"name": "Action"
},
{
"id": 12,
"name": "Adventure"
},
{
"id": 878,
"name": "Science Fiction"
}
],
"homepage": "http://www.rampagethemovie.com",
"id": 427641,
"imdb_id": "tt2231461",
"original_language": "en",
"original_title": "Rampage",
...
}
I have setup a model class for to parse this and the class is defined as such:
import 'dart:async';
class MovieDetail {
final String title;
final double rating;
final String posterArtUrl;
final backgroundArtUrl;
final List<Genre> genres;
final String overview;
final String tagline;
final int id;
const MovieDetail(
{this.title, this.rating, this.posterArtUrl, this.backgroundArtUrl, this.genres, this.overview, this.tagline, this.id});
MovieDetail.fromJson(Map jsonMap)
: title = jsonMap['title'],
rating = jsonMap['vote_average'].toDouble(),
posterArtUrl = "http://image.tmdb.org/t/p/w342" + jsonMap['backdrop_path'],
backgroundArtUrl = "http://image.tmdb.org/t/p/w500" + jsonMap['poster_path'],
genres = (jsonMap['genres']).map((i) => Genre.fromJson(i)).toList(),
overview = jsonMap['overview'],
tagline = jsonMap['tagline'],
id = jsonMap['id'];
}
class Genre {
final int id;
final String genre;
const Genre(this.id, this.genre);
Genre.fromJson(Map jsonMap)
: id = jsonMap['id'],
genre = jsonMap['name'];
}
My issue is that I can't get the genre to parse properly from the JSON. When I get the JSON and pass it through my model class, I get the following error:
I/flutter (10874): type 'List<dynamic>' is not a subtype of type 'List<Genre>' where
I/flutter (10874): List is from dart:core
I/flutter (10874): List is from dart:core
I/flutter (10874): Genre is from package:flutter_app_first/models/movieDetail.dart
I thought this would work because I have made a different class for the Genre object and passed in the JSON array as a list. I don't understand how List<dynamic> isn't a child of List<Genre> because doesn't the keyword dynamic imply any object? Does anyone know how to parse a nested JSON array into custom objects?
Try genres = (jsonMap['genres'] as List).map((i) => Genre.fromJson(i)).toList()
The issue: calling map without the cast makes it a dynamic call, which means the return type from Genre.fromJson is also dynamic (not Genre).
Take a look at https://flutter.io/json/ for some hints.
There are solutions, like https://pub.dartlang.org/packages/json_serializable, that makes this much easier
I think JSONtoDart Converter is very useful, Must try...
After receiving the response, first of all, you need to extract the arrays separately. Then you can easily map. This is the way I do it.
List<Attempts> attempts;
attempts=(jsonDecode(res.body)['message1'] as List).map((i) => Attempts.fromJson(i)).toList();
List<Posts> posts;
attempts=(jsonDecode(res.body)['message2'] as List).map((i) => Post.fromJson(i)).toList();
Refer below example.
Future<List<Attempts>> getStatisticData() async {
String uri = global.serverDNS + "PaperAttemptsManager.php";
var res = await http.post(
uri,
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(<String, String>{
'userName': widget.userId,
'subject': widget.subjectName,
'method': "GETPTEN",
}),
);
if (res.statusCode == 200) {
List<Attempts> attempts;
attempts=(jsonDecode(res.body)['message'] as List).map((i) => Attempts.fromJson(i)).toList();
return attempts;
} else {
throw "Can't get subjects.";
}
}
Model Class
class Attempts {
String message, userName, date, year, time;
int status, id, marks, correctAnswers, wrongAnswers, emptyAnswers;
Attempts({
this.status,
this.message,
this.id,
this.userName,
this.date,
this.year,
this.marks,
this.time,
this.correctAnswers,
this.wrongAnswers,
this.emptyAnswers,
});
factory Attempts.fromJson(Map<String, dynamic> json) {
return Attempts(
status: json['status'],
message: json['message'],
id: json['ID'],
userName: json['USERNAME'],
date: json['DATE'],
year: json['YEAR'],
marks: json['MARKS'],
time: json['TIME'],
correctAnswers: json['CORRECT_ANSWERS'],
wrongAnswers: json['WRONG_ANSWERS'],
emptyAnswers: json['EMPTY_ANSWERS'],
);
}
}