Firebase nested HttpsCallableResult to dart model - json

I'm trying to get some data from a cloud function and assign it to a model. But I am unable to used the nested data, I get the following error:
_TypeError (type '_InternalLinkedHashMap<Object?, Object?>' is not a subtype of type 'Map<String, dynamic>')
The data I receive looks like this:
{
"answer": "Some optional answer",
"error": "Some optional error",
"usage": { "prompt_tokens": 32, "completion_tokens": 40, "total_tokens": 72 }
}
When I receive the data I try to assign it to a model:
final HttpsCallableResult result = await functions
.httpsCallable('askHW')
.call({'question': userQuestion});
return HWResponse.fromJson(result.data);
HWResoponse:
class HWResponse {
final String answer;
final String error;
final HWUsage usage;
HWResponse({this.answer = '', this.error = '', required this.usage});
factory HWResponse.fromJson(Map<String, dynamic> json) => HWResponse(
answer: json.containsKey('answer') ? json['answer'] as String : '',
error: json.containsKey('error') ? json['error'] as String : '',
usage:
json["usage"] == null ? HWUsage() : HWUsage.fromJson(json["usage"]),
);
Map<String, dynamic> toJson() => {
"answer": answer,
"error": error,
"usage": usage.toJson(),
};
}
class HWUsage {
final int promptTokens;
final int completionTokens;
final int totalTokens;
HWUsage({
this.promptTokens = 0,
this.completionTokens = 0,
this.totalTokens = 0,
});
factory HWUsage.fromJson(Map<String, dynamic> json) => HWUsage(
promptTokens: json.containsKey('prompt_tokens')
? json['prompt_tokens'] as int
: 0,
completionTokens: json.containsKey('completion_tokens')
? json['completion_tokens'] as int
: 0,
totalTokens:
json.containsKey('total_tokens') ? json['total_tokens'] as int : 0,
);
Map<String, dynamic> toJson() => {
"prompt_tokens": promptTokens,
"completion_tokens": completionTokens,
"total_tokens": totalTokens,
};
}

Using Map<String, dynamic>.from('json['usage]') in HWResponse on the nested field seems to be the correct way to do this. To avoid any errors I also used json.containsKey('usage') to make sure that the nested field usage actually exists.
usage: json.containsKey('usage')
? HWUsage.fromJson(Map<String, dynamic>.from(json['usage']))
: HWUsage(),

Related

NoSuchMethodError : The method 'map' was called on null. Plz Provide the Solution

I am trying to parse data from a Rest API inside a Dart/Flutter application.
The JSON contains a field called data at the root, which contains a list of Words.
I want to get a List<ArticalList> from this JSON giving json["data"].map((x) => ArticalList.fromJson(x))
I already have the following code:
import 'dart:convert';
Welcome welcomeFromJson(String str) => Welcome.fromJson(json.decode(str));
String welcomeToJson(Welcome data) => json.encode(data.toJson());
class Welcome {
Welcome({
required this.code,
required this.status,
required this.message,
required this.data,
});
final int code;
final String status;
final String message;
final List<ArticalList> data;
factory Welcome.fromJson(Map<String, dynamic> json) => Welcome(
code: json["code"] ?? 0,
status: json["status"] ?? '',
message: json["message"] ?? '',
data: List<ArticalList>.from(json["data"].map((x) => ArticalList.fromJson(x))),
);
Map<String, dynamic> toJson() => {
"code": code,
"status": status,
"message": message,
"data": List<dynamic>.from(data.map((x) => x.toJson())),
};
}
class ArticalList {
ArticalList({
required this.id,
required this.title,
required this.detail,
required this.image,
});
int id;
String title;
String detail;
String image;
factory ArticalList.fromJson(Map<String, dynamic> json) => ArticalList(
id: json["id"] == null ? 0 : json["id"],
title: json["title"] == null ? '' : json["title"],
detail: json["detail"] == null ? '' : json["detail"],
image: json["image"] ?? 'http://eduteksolutions.in/images/logo.jpeg',
);
Map<String, dynamic> toJson() => {
"id": id == null ? null : id,
"title": title == null ? null : title,
"detail": detail == null ? null : detail,
"image": image,
};
}
I think your getting error at
data: List<ArticalList>.from(json["data"].map((x) => ArticalList.fromJson(x))),
I create a function with null safety which accept map and return object list
static List<ArticalList> toListFormMap({
Map? map,
}) {
if (map?.isEmpty ?? true) return [];
List<ArticalList> items = [];
map?.forEach((key, data) {
final ArticalList item = ArticalList.fromJson(data);
items.add(item);
});
return items;
}
and same method which convert map to Map
static Map toMapList(List<ArticalList>? items) {
Map map = {};
items?.forEach((element) {
map[element.id] = element.toJson();
});
return map;
}
for both case it handle null data error and also convert Object List to Map list and Map list to Object list.
I hope it will be helpful.

How to parse dynamic JSON keys in dart

I have an API that returns JSON with dynamic keys, i.e. the key value changes on every GET request.
Ex: This is the format of the JSON.
I have a book model in dart,
class Book {
String id = "";
String title = "";
Book();
Book.fromJson(Map<String, dynamic> json) {
id = json['id'];
title = json['title'];
}
static List<Book> listFromJson(List<dynamic> json) {
return json.map((val) => Book.fromJson(val)).toList();
}
}
and JSON response,
{
"Recommended For You" : [
{
"id" : "001",
"title" : "title001"
},
...
],
"Thrillers" : [
{
"id" : "005",
"title" : "title005"
},
...
]
}
How to parse this into lists of books according to the genre, given that genres (like Thrillers) can change(i.e. it is dynamic and may change for each user)?
Edit 1
Thrillers and Recommended For You aren't constant, some times it may change to Horror and Romantic or something else. It is dynamic
Edit 2 : The solution
Thanks to #lrn's solution, I came up with a new Class
class Recommendations {
String recommendationType;
List<Book> recommendations;
#override
String toString() {
return 'Recomendations[title: $recommendationType]';
}
Recommendations.fromJson(MapEntry<String, dynamic> json) {
if (json == null) return;
this.recommendationType = json.key;
this.recommendations = Book.listFromJson(json.value);
}
static List<Recommendations> listFromJson(Map<String, dynamic> json) {
return json == null
? List<Recommendations>.empty()
: json.entries
.map((value) => new Recommendations.fromJson(value))
.toList();
}
}
If you don't know the keys, but do know that it's a JSON map where the values are the book lists you're looking for, I'd write:
List<Book> parseCategorizedBooksJson(Map<String, dynamic> json) =>
[for (var books in json.values) ...Book.listFromJson(books)];
or
List<Book> parseCategorizedBooksJson(Map<String, dynamic> json) =>
[for (var books in json.values)
for (var book in books) Book.fromJson(book)];
(which avoids building intermediate lists of books).
With this you simply iterate the values of the outer map, and ignore the keys. JSON maps are just plain Dart Maps and you can access the keys as .keys (and then go trough them without needing to known them ahead of time) and access the values as .values (and completely ignore the keys).
Each value is a list of books, which you can parse using your existing static functions.
To include the genre, you have to say how you want the genre remembered. The simplest is to retain the data as a map:
var categoriedBooks = {for (var genre in json)
genre: Book.listFromJson(json[genre])
};
This builds a map with the same keys (the genres), but where the values are now lists of Books.
Your response model contains two different arrays, recommendedForYou and thrillers. So, you can handle it like this:
// To parse this JSON data, do
//
// final responseModel = responseModelFromJson(jsonString);
import 'dart:convert';
ResponseModel responseModelFromJson(String str) => ResponseModel.fromJson(json.decode(str));
String responseModelToJson(ResponseModel data) => json.encode(data.toJson());
class ResponseModel {
ResponseModel({
this.recommendedForYou,
this.thrillers,
});
List<Book> recommendedForYou;
List<Book> thrillers;
factory ResponseModel.fromJson(Map<String, dynamic> json) => ResponseModel(
recommendedForYou: json["Recommended For You"] == null ? null : List<Book>.from(json["Recommended For You"].map((x) => Book.fromJson(x))),
thrillers: json["Thrillers"] == null ? null : List<Book>.from(json["Thrillers"].map((x) => Book.fromJson(x))),
);
Map<String, dynamic> toJson() => {
"Recommended For You": recommendedForYou == null ? null : List<dynamic>.from(recommendedForYou.map((x) => x.toJson())),
"Thrillers": thrillers == null ? null : List<dynamic>.from(thrillers.map((x) => x.toJson())),
};
}
class Book {
Book({
this.id,
this.title,
});
String id;
String title;
factory Book.fromJson(Map<String, dynamic> json) => Book(
id: json["id"] == null ? null : json["id"],
title: json["title"] == null ? null : json["title"],
);
Map<String, dynamic> toJson() => {
"id": id == null ? null : id,
"title": title == null ? null : title,
};
}
You can use this site to convert your json to any dart model.

Problem with fetch: '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List<dynamic>'

I'm trying to fetch data from an API, but I keep getting this error.
Problem with fetch: '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List'
Please tell me how to fix this code.
Model.dart
class ComprovanteModel {
ComprovantesInfoModel jsonResponse;
String error;
ComprovanteModel({this.jsonResponse, this.error});
ComprovanteModel.fromJson(Map<String, dynamic> json)
: jsonResponse = ComprovantesInfoModel.fromJson(json['json_response']),
error = '';
ComprovanteModel.withError(String errorValue)
: jsonResponse = null,
error = errorValue;
}
class ComprovanteInfoModel {
String clientFormalName;
int volumes;
int duration;
CheckpointsModel checkpoint;
ComprovanteInfoModel({
this.clientFormalName,
this.duration,
this.volumes,
this.checkpoint,
});
ComprovanteInfoModel.fromJson(Map<String, dynamic> json)
: clientFormalName = json['client_formal_name'],
checkpoint = CheckpointsModel.fromJson(json['checkpoint']),
volumes = json['volumes'],
duration = json['duration'];
}
class CheckpointModel {
int checkpointId;
String arrivalTime;
int status;
CheckpointModel({
this.checkpointId,
this.arrivalTime,
this.status,
});
CheckpointModel.fromJson(Map<String, dynamic> json)
: checkpointId = json['checkpoint_id'],
arrivalTime = json['arrival_time'],
status = json['status'];
}
class CheckpointsModel {
List<CheckpointModel> checkpoint;
CheckpointsModel({this.checkpoint});
CheckpointsModel.fromJson(List<dynamic> jsonList)
: checkpoint = jsonList.map((e) => CheckpointModel.fromJson(e)).toList();
}
The API response:
{
"json_response": [
{
"client_formal_name": "",
"deadline": null,
"volumes": 1,
"duration": 5,
"depot_id": 20,
"service_id": 109856,
"georef_provider": "ap_geocoder",
"checkpoint": {
"checkpoint_id":,
"arrival_time": "",
"duration":,
"status": 1,
"event_id": 5,
"resources": [
{
"content_type": "PHOTO",
"service_event_effect_id": 58,
"content": "em+ndG6XtE2unp",
"content_label": "",
"user_effect_unique_code": ""
},
{
"content_type": "RECEPTOR_INFO",
"service_event_effect_id": 61,
"content": "{\"user_relationship_unique_code\":\"\",\"is_expected_receiver\":\"true\",\"document\":\"65979973000240\",\"name\":\"",\"description\":\"",\"id\":\"1\"}",
"content_label": "",
"user_effect_unique_code": "2"
}
],
"event_description": "",
"operation_date": "",
"obs": "",
"is_assistant": false,
"image": "{\"description\": \"Documento\", \"photo\": \""}"
},
"final_attendance_window_b": null
}
]
}
I want to access the checkpoint item, then the resource item(which I think is the same process as the checkpoint). I am using the list but I don't think is right, I am suppose to use map but I don't know how. Please show me a way.
Change this:
ComprovanteModel.fromJson(Map<String, dynamic> json)
: jsonResponse = ComprovantesInfoModel.fromJson(json['json_response']),
error = '';
To this:
ComprovanteModel.fromJson(Map<String, dynamic> json)
: jsonResponse = ComprovantesInfoModel.fromJson(json['json_response'][0]), //added [0] here.
error = '';
If you look closely at your response, it does have the map that you need, but this map is actually inside a list, notice the square brackets [ ] around the {} in "json_response": [.
The map that you need to access, is at index[0] of this list, then everything will work fine.
Second thing, this:
CheckpointsModel.fromJson(List<dynamic> jsonList)
: checkpoint = jsonList.map((e) => CheckpointModel.fromJson(e)).toList();
}
You are telling Flutter that you will pass an object of type List<dynamic> , but in the json you post, "checkpoint": { is not a list, it's a map. But even so, this map has only one checkpoint.
To answer your last question
I wanna access the checkpoint item, then the resource item(wich i
think is the same process as the checkpoint).
"resources": [ is indeed a list of Maps. In your code you did not post your resources model, but I'm assuming you want a List<Resources> and not List<CheckPoint>, it'll look like this:
class SingleResourceModel {
String contentType;
int serviceId;
String content;
String contentLabel;
String uniqueCode;
SingleResourceModel({
this.contentType,
this.serviceId,
this.content,
this.contentLabel,
this.uniqueCode
});
SingleResourceModel.fromJson(Map<String, dynamic> json)
: contentType = json['content_type'],
serviceId = json['service_event_effect_id'],
content = json['content'];
contentLabel = json['content_label'],
uniqueCode = json['user_effect_unique_code'];
}
class ListResourceModel {
List<SingleResourceModel> resourcesList;
ListResourceModel({this.resourcesList});
ListResourceModel.fromJson(List<Map<String, dynamic>> jsonList)
: resourcesList = jsonList.map((e) => SingleResourceModel.fromJson(e)).toList();
}
Finally, you can modify your CheckPoint model, and add to it a ListResourceModel, to look like this in the end:
class CheckpointModel {
int checkpointId;
String arrivalTime;
int status;
ListResourceModel resourcesList;
CheckpointModel({
this.checkpointId,
this.arrivalTime,
this.status,
this.resourcesList
});
CheckpointModel.fromJson(Map<String, dynamic> json)
: checkpointId = json['checkpoint_id'],
arrivalTime = json['arrival_time'],
status = json['status'],
resourcesList= json['resources'];
}
Now, you should be all set.

Flutter converting Nested Object from Json returns null

I have a Nested Object like this just a bit bigger:
"name": "String",
"exercise": [
{
"index": 1,
}
],
"pause": [
{"index":2},
]
I convert the exercise and pause to a Json String and save them in a column in SQFLite.
The problem
When I read the Data everything works fine including the List (not nested) but both list's of nested Object are empty when I read a value of the nested object it gives an error.
item.exercise[0].index.toString()
Valid Value range is empty: 0
When I read only item.exercise.toString() it returns []. Without != null ? [...] : List<Exercise>() it also throws an error
Data I get from my Database (shortened)
List of:
[{name: number 1, id: 56, exercise: [{"index":1,"weightGoal":[15,16,17]}, {"index":3,"weightGoal":[15,16,17]}], pause: [{"index":2}]},{"index":4}]}]
What I do with it
Here I try to go through the list and convert it into a List of PlanModel:
List<PlanModel> list =
res.isNotEmpty ? res.map((c) => PlanModel.fromJson(c)).toList() : [];
return list;
Full model
PlanModel planModelFromJson(String str) => PlanModel.fromJson(json.decode(str));
String planModelToJson(PlanModel data) => json.encode(data.toJson());
class PlanModel {
PlanModel({
this.name,
this.id,
this.workoutDays,
this.pastId,
this.timesDone,
this.exercise,
this.pause,
});
String name;
int id;
List<String> workoutDays;
int pastId;
int timesDone;
List<Exercise> exercise;
List<Pause> pause;
factory PlanModel.fromJson(Map<String, dynamic> json) => PlanModel(
name: json["name"],
id: json["id"],
workoutDays: List<String>.from(jsonDecode(json["workoutDays"])),
pastId: json["pastId"],
timesDone: json["timesDone"],
exercise: json["Exercise"] != null ? new List<Exercise>.from(json["Exercise"].map((x) => Exercise.fromJson(x))): List<Exercise>(),
pause: json["Pause"] != null ? new List<Pause>.from(json["Pause"].map((x) => Pause.fromJson(x))): List<Pause>(),
);
Map<String, dynamic> toJson() => {
"name": name,
"id": id,
"workoutDays": List<dynamic>.from(workoutDays.map((x) => x)),
"pastId": pastId,
"timesDone": timesDone,
"Exercise": List<dynamic>.from(exercise.map((x) => x.toJson())),
"Pause": List<dynamic>.from(pause.map((x) => x.toJson())),
};
}
class Exercise {
Exercise({
this.index,
this.name,
this.goal,
this.repGoal,
this.weightGoal,
this.timeGoal,
this.setGoal,
});
int index;
String name;
int goal;
int repGoal;
List<int> weightGoal;
int timeGoal;
List<String> setGoal;
Exercise.fromJson(dynamic json) {
// anything that is wrapped around with this [] in json is converted as list
// anything that is wrapped around with this {} is map
index = json["index"];
name = json["name"];
goal = json["goal"];
repGoal = json["repGoal"];
weightGoal = json["weightGoal"] != null ? json["weightGoal"].cast<int>() : [];
timeGoal = json["timeGoal"];
setGoal = json["setGoal"] != null ? json["setGoal"].cast<String>() : [];
}
Map<String, dynamic> toJson() => {
"index": index,
"name": name,
"goal": goal,
"repGoal": repGoal,
"weightGoal": List<dynamic>.from(weightGoal.map((x) => x)),
"timeGoal": timeGoal,
"setGoal": List<dynamic>.from(setGoal.map((x) => x)),
};
}
class Pause {
Pause({
this.index,
this.timeInMilSec,
});
int index;
int timeInMilSec;
factory Pause.fromJson(Map<String, dynamic> json) => Pause(
index: json["index"],
timeInMilSec: json["timeInMilSec"],
);
Map<String, dynamic> toJson() => {
"index": index,
"timeInMilSec": timeInMilSec,
};
}
Read this first.
You need to tweek this code a little to work for you but the idea is that;
also read comment in the code.
if json string comes with [] those around, json.decode will decode it as List<Map>.
if it comes with {} this json.decode will decode it as Map.
note: be careful while using generics on json.decode I reccommend not to.
data inside the jsonString does not really corresponds with the values inside the fromJson function. json string which you have provided was not really good. so I think you will understand how to manipulate it for your needs.
also main constructor Exercise you can use for initial data.
import 'dart:convert';
class Exercise{
Exercise({this.index,
this.name,
this.repGoal,
this.weightGoal,
this.setGoal});
String index;
String name;
String repGoal;
String weightGoal;
String setGoal;
Exercise.fromJson(dynamic json) :
// anything that is wrapped around with this [] in json is converted as list
// anything that is wrapped around with this {} is map
index = json["exercise"][0]["index"].toString(),
name = json["name"].toString(),
repGoal = json["repGoal"].toString(),
weightGoal = json["weightGoal"].toString(),
setGoal = json["setGoal"].toString();
}
void main(){
String jsonString = '{name: number 1, id: 56, exercise: [{"index":1,"weightGoal":[15,16,17], pause: [{"index":2}]}';
Map json = json.decode(jsonString);
Exercise.fromJson(json);
}
I found it out :)
I have restructured my fromJson to this, especially the jsonDecode was important, because json["exercise "] was only a String.
PlanModel.fromJson(dynamic json) {
name = json["name"];
if (json["exercise"] != null) {
exercise = [];
jsonDecode(json["exercise"]).forEach((v) {
exercise.add(Exercise.fromJson(v));
});
}}
now I can access it with
PlanModel item = snapshot.data[index];
item.exercise[0].timeGoal.toString()

(Resolved)(type 'String' is not a subtype of type 'int') - Flutter

This question has already been answered, continue reading if you think you have the same error, the answer was given by the user: Tariqul Islam
since a few days ago there was a flutter update my code shows the following error:
_TypeError (type 'String' is not a subtype of type 'int')
Obviously the application worked perfectly before this update, even after changing from "int" to "String" the same error I get but the other way around:
_TypeError (type 'int' is not a subtype of type 'String')
As much as I change the values ​​the same error still appears to me, it is also clear that the RestApi that I am using did not have any changes.
I get the error when I get to "Chip", after I change it to String I get the same error in "Number", and after I change both the same error appears but the other way around as I indicated above
Here the Json file model:
class EventoModel {
String id;
String nombreEvento;
List<Participantes> participantes;
EventoModel({
this.id,
this.nombreEvento,
this.participantes
});
factory EventoModel.fromJson(Map<String, dynamic> parsedJson){
var list = parsedJson['participantes'] as List;
//print(list.runtimeType);
List<Participantes> participantesList = list.map((i) => Participantes.fromJson(i)).toList();
return EventoModel(
id : parsedJson ['id'],
nombreEvento : parsedJson ['nombreEvento'],
participantes : participantesList
);
}
}
class Participantes {
String uniqueId;
String apellido;
int chip;
String nombre;
int numero;
String place;
String tiempo;
Participantes({
this.apellido,
this.chip,
this.nombre,
this.numero,
this.place,
this.tiempo,
});
factory Participantes.fromJson(Map<String, dynamic> parsedJson) {
//print(list.runtimeType);
return Participantes(
apellido : parsedJson['Apellido'],
chip : parsedJson['Chip'],
nombre : parsedJson['Nombre'],
numero : parsedJson['Numero'],
place : parsedJson['Place'],
tiempo : parsedJson['Tiempo'],
);
}
Map<String, dynamic> toJson() {
return {
'Apellido' : apellido,
'Chip' : chip,
'Nombre' : nombre,
'Numero' : numero,
'Place' : place,
'Tiempo' : tiempo,
};
}
}
This is the Json file Example:
{
"nombreEvento" : "Clasico El Colombiano 2020",
"participantes" : [ {
"Apellido" : "MARTINEZ GUTIERREZ",
"Chip" : "739",
"Nombre" : "JOSE",
"Numero" : "139",
"Place" : "1.",
"Tiempo" : "00:30:12,91"
}, {
"Apellido" : "SUAREZ MORERA",
"Chip" : "707",
"Nombre" : "DANIEL",
"Numero" : "107",
"Place" : "2.",
"Tiempo" : "02:00:17,54"
}, {
"Apellido" : "RODRIGUEZ VARGAS",
"Chip" : "1686",
"Nombre" : "JOSE LUIS",
"Numero" : "274",
"Place" : "3.",
"Tiempo" : "02:01:09,09"
}
]
}
Could someone please help me? : c
If the type of a variable is not explicitly specified, the variable’s type is dynamic. The dynamic keyword can also be used as a type annotation explicitly.
Instead of int you can use dynamic and it will solve the issue.
class Participantes {
String uniqueId;
String apellido;
dynamic chip;
String nombre;
dynamic numero;
String place;
String tiempo;
Participantes({
this.apellido,
this.chip,
this.nombre,
this.numero,
this.place,
this.tiempo,
});
I had like this issue and in this case I did defining type from int to dynamic then it solved. For example: In firebase side I defined number type and I read it with type of dynamic. If you do int in your codes it will warned you "type 'int' is not a subtype of type 'String'" but if you define dynamic it will solve.
Code sample is in below.
//class Survey
class Survey {
String name;
dynamic vote; // before it was int type and I have changed
DocumentReference reference;
Survey.fromMap(Map<String, dynamic> map, {this.reference})
//datanın var olup olmadığını kontrol et eğer varsa kullan
: assert(map["name"] != null),
assert(map["vote"] != null),
name = map["name"],
vote = map["vote"];
Anket.fromSnapshot(DocumentSnapshot snapshot)
: this.fromMap(snapshot.data(), reference: snapshot.reference);
}
Just do int chip to String chip, and int numero to String numero because in your JSON data comes in String
class Participantes {
String uniqueId;
String apellido;
String chip;
String nombre;
String numero;
String place;
String tiempo;
Participantes({
this.apellido,
this.chip,
this.nombre,
this.numero,
this.place,
this.tiempo,
});
In Json you are receiving Chip and Numero as String but in your model file you are declaring as integer. change the datatype to String in your model file.
String numero;
String chip;
From the JSON you provided I have made a model class below:
check out and let me know:
// To parse this JSON data, do
//
// final eventoModel = eventoModelFromJson(jsonString);
import 'dart:convert';
EventoModel eventoModelFromJson(String str) => EventoModel.fromJson(json.decode(str));
String eventoModelToJson(EventoModel data) => json.encode(data.toJson());
class EventoModel {
String nombreEvento;
List<Participante> participantes;
EventoModel({
this.nombreEvento,
this.participantes,
});
factory EventoModel.fromJson(Map<String, dynamic> json) => EventoModel(
nombreEvento: json["nombreEvento"],
participantes: List<Participante>.from(json["participantes"].map((x) => Participante.fromJson(x))),
);
Map<String, dynamic> toJson() => {
"nombreEvento": nombreEvento,
"participantes": List<dynamic>.from(participantes.map((x) => x.toJson())),
};
}
class Participante {
String apellido;
String chip;
String nombre;
String numero;
String place;
String tiempo;
Participante({
this.apellido,
this.chip,
this.nombre,
this.numero,
this.place,
this.tiempo,
});
factory Participante.fromJson(Map<String, dynamic> json) => Participante(
apellido: json["Apellido"],
chip: json["Chip"],
nombre: json["Nombre"],
numero: json["Numero"],
place: json["Place"],
tiempo: json["Tiempo"],
);
Map<String, dynamic> toJson() => {
"Apellido": apellido,
"Chip": chip,
"Nombre": nombre,
"Numero": numero,
"Place": place,
"Tiempo": tiempo,
};
}